Is there any Webhook for Reddit to catch messages? - webhooks

I'm creating a platform to manage reddit messages. I need to catch the messages as soon as they are posted and to answer back. How can I receive a message as soon as it is posted, and how I can answer back with a PM to the sender?

No, there's simply no webhooks provided by Reddit.
Instead, you need to poll the API instead. You can use the JSON, RSS, or XML API in order to get information from Reddit's API.
You can use /api/comment to reply to a message.

Related

How to create a bot in lex/azure that respond in slack threads?

I have created 2 chatbots using AWS lex and Azure bot framework each. I have integrated them with slack and they respond to the mentions in channels.
Currently, the bot responds as a new message however I want it to respond in the slack thread of the original message posted by the user. I tried to look for articles in various places but could not find anything helpful. Does anyone have any idea on how to achieve this or a reference to a GitHub repo for a sample?
Since you are able to post replies, I am assuming that you are using chat.postMessage API.
https://api.slack.com/methods/chat.postMessage
To send the reply as a thread, all you need to do is that add thread_ts argument in the api call.
(Provide original message's ts (timestamp) value to make this message a reply.)

how can I send a string with the following data to the next Slack Incoming Webhook

how can I send a string with the following data to the next Slack Incoming Webhook https://hooks.slack.com/services/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
Just post a request to the URL in JSON. e.g.:
{
"text": "I would advise not to publish your real Slack webhooks on Stackoverflow. People might abuse it. :-D"
}
Other formats will work too.
You can use a website like https://www.hurl.it/ to test it.
There are more option you can use, e.g. channel. Check the official documentation here for details.

BadArgument:Security token not valid for this conversation

I'm trying to use Direct Line API of microsoft bot framework,
Following steps are followed.
Got Conversation Id from application(running on node.js)
[conversationId123]
Create Conversation Token from postman
https://directline.botframework.com/api/tokens/conversation
[ConversationToken456]
Get Conversation Messages using conversationId123 & Authorization header using ConversationToken456
https://directline.botframework.com/api/conversations/conversationId123/messages
I receive
BadArgument:Security token not valid for this conversation
Did I miss something?
Hard to know what's going wrong without seeing the whole flow; though the error indicates that the token is invalid.
Here is a DirectLine sample using Node.js. You might want to use it as the baseline for your sample and I'm pretty sure you will find out the error.
I think before sending a message to the BOT you should call the URL stream that returns from the initial "Start conversation" POST request. At least that appears at the documentation
In my case, using C# I'm able to retrieve a token, then message ID and even request the bot to send me a list of activities, but I'm unable to send a message (the POST request never comes back with an answer)

Telegram Bot webhook really slow

I've created a telegram bot and set a webhook as described in the docs. For testing purposes I've set it up so once you send the bot a message it replies back with the same message.
Now the issue I am having is that the updates from telegram are coming back really slowly and there are some messages I haven't received yet. Am I missing something or is the webhook method just really slow?
I had the same problem. Turns out I wasn't responding the telegram server after I got the POST request. Due to this, the server wasn't sure if I got the previous updates and was constantly sending my webhook past updates.
I have an express server and I added this bit of line after handling the POST Request.
res.sendStatus(403)
You can also confirm this by going to this url
https://api.telegram.org/<token>/getWebhookInfo
You'll see a property called pending_update_count. It should zero or close to it.

How to associate sendgrid webhook sg_message_id to sent mail?

Sendgrid webhook has sg_message_id
But the response of Web API v2 when sending mail doesn't have sg_message_id.
In fact, there is only message showing only success or failed.
So, how do i associate between sent mail and the webhook callback?
I have check the past questions in SO but it doesn't provide be the solution for this.
Thank you.
You can use unique arguments. Take your unique ID (like primary key) and give it to sendgrid API during sending email. You will get it back in the event webhook.
https://sendgrid.com/docs/API_Reference/SMTP_API/unique_arguments.html
EDIT: The best practice seems to be using custom arguments (see documentation). Which is not apparent from the documentation (as of today).
In Web API v3, the response includes a special header X-Message-Id (see https://sendgrid.com/docs/Glossary/x_message_id.html).
This can be later matched with sg_message_id in webhook: https://sendgrid.com/docs/Glossary/message_id.html
The documentation does not make it clear, but the X-Message-Id header is actually not equal to sg_message_id, but it is a prefix of sg_message_id.
For example:
X-Message-Id = "MUvGg3V1ThOu3oe8eRqFrA"
sg_message_id = "MUvGg3V1ThOu3oe8eRqFrA.filter0001p2iad2-21183-5AF0BD9B-E.0"
The Web APIv2 call that sends out the email only responds with a {message :"success"} answer indeed, but the sg_message_id is not generated at that point. The API call answer simply acknowledges that the email was sent to SendGrid for processing.
The email is sent to SendGrid, and there it receives the sg_message_id value that is provided through the Event Webhook posts.

Resources