Receiving notifications from Slack Direct messages - slack-api

I'm building a simple slack bot and can currently send private messages as well as checking for the last 10 messages received within this one-to-one channel.
Is there a way of getting a POST notification to my webservice whenever the user replies, instead of having to poll and continuously check messages on that one-to-one channel?

Now you can make use of Slack events to receive notifications.
In the give use-case, 'Message' event can be used to capture message received and process accordingly.
https://api.slack.com/events/message

Bots generally work by connecting to the real-time messaging API, a WebSocket-based API that sends you events as they happen. Specifically, you should see a message event sent to you every time a message visible to your bot is sent.
To answer your question, there's no way to get an HTTP POST sent to you instead; you'll need to connect to the RTM API and listen for events that way.

Related

Retrieve twilio voice logs via webhook

I've checked the documentation and it explains how to retrieve call logs via API calls, but there does not seem to be a webhook available whenever a log is created :')
Is there an easy way to get notified whenever twilio creates a log for any number?
Twilio doesn't have webhooks that are fired on the creation of call logs.
You could however utilise the incoming call & status callback webhooks on phone numbers within the account to determine when specific actions are fired and begin any actions needed.

How to unsubscribe messaging/voice webhook to stop receiving events occurred in a number?

In Twilio, after we register a webhook URL in an active number, we'll be able to get event notifications whenever events occour in the registered number depending on the type of webhook we registered (Voice/SMS).
The registration of the webhook can be achieved via REST API. Similarly is there any API to stop the webhook notification? Else how should we handle this?
The same API, incomingPhoneResource, would be used do the same. You should be able to create, read, update and delete the configured webhooks for voice and SMS phone number configurations this way.

How to know that a specfic incoming sms is a reply to a previous outgoing sms?

I am integrating Twilio SMS service where my users are able to send SMS messages to their clients. I would like to be able to link each reply with the sent SMS. In another word, is there any field in the Message Resource that could lead me to conclude whether the incoming message received is related to the outgoing message my user sent previously ? I need same behavior as Email send/reply functionalities.
Twilio developer evangelist here.
There is no way to do this I’m afraid, the SMS protocol has no information about users replying to a specific message. SMS is chronological, you can test this by opening your phone’s SMS app and trying to reply to the second to last message you received from someone. In SMS there’s no way to do that.
The best thing you can do is consider the messages chronologically, and assume that the reply is in response to the last message you sent to that number from the number you sent it from.
I suspect your are interested in this because you need to send notifications and get responses to those notifications and you realised you might need to send more than one notification to a user at a time but still get their responses. The best way to get around this is to use different numbers to send the different notification messages from, then when they reply you can tell which notification they were replying to by the number they sent the message to.

iOS Twilio Receive Incoming SMS

I am developing an iOS messaging app that uses Twilio to send and receive SMS and MMS. The tutorial on Twilio about the iOS client seems to only cover outgoing and incoming calls. I understand that sending an SMS/MMS would mean that I send a HTTP request to my server, in which my server sends the request to Twilio in order to complete the sending. However, how would I receive messages on my app?
I know that Twilio numbers have web hooks that execute when the number receives this message, but how would I get this message to my app. I don't believe that there are delegate methods included like the voice ones. The only solution that I could think of right now would be to use push notifications from my server to the phone. Is there any other possible way? Thanks.
I was recently in a similar situation to yours, but my app only cares about receiving a response within a 2 minute window while the app is opened.
Regardless, I would say that your best options include 1) push notifications, 2) sockets (probably via Socket.io), or 3) background polling. If you plan to have your application receive the message agnostic of its state (open, closed, etc), then I would highly suggest using push notifications. I'm using Parse as my Twilio backend and it makes creating and working with push notifications a breeze :)

IM app, how to ensure the other side received my message?

I am writing a IM app on iOS, and not sure about how to ensure that the other side has received my message. Could anyone give me some suggestions or existing frameworks?
You can have the device that receives a message send data back that confirms the message has been received. Most likely each message would be assigned a unique id that the receiving device would send back so that it knows specifically which message was received.
I am not familiar with Pubnub but looking quickly at their SDK it looks like you can send messages both directions on a single channel, or else you could setup one channel for sending messages and one channel for confirming messages.

Resources