Navigating an IVR with Twilio - ruby

I am trying to navigate an known IVR, that ends with the last input forwarding to a real person. When that person picks up, I want to make a call back to the app to play an mp3. Using sendDigits https://www.twilio.com/docs/api/rest/making-calls#post with call creation works for navigating the menu, but the callback to the url parameter happens when the call is answered by the IVR instead of the end user. So in that case, the mp3 is already playing by the time the person the call is forwarded to answers.
The other way I was thinking of trying involved not using sendDigits with call creation, but using a different url callback to grab TwiML and use Play https://www.twilio.com/docs/api/twiml/play to play the DTMF tones needed. In this scenario though, reading though the docs, I don't see a way to send a callback url that would be called when the call is forwarded and the person picks up.
Any suggestions?

Twilio developer evangelist here.
If you want a webhook when your DTMF tones are finished and the call is put through to a human, you could try your second option using <Play> to send DTMF tones and then use a <Redirect> to cause a new webhook to occur. Like this:
<Response>
<Play digits="1234"></Play>
<Redirect>http://example.com/play_mp3</Redirect>
</Response>
If you find that you are still playing the mp3 before a person has actually answered, you can use <Pause> to wait before sending the <Redirect>.
Let me know if that helps at all.

Related

Twilio Flex Voicemail messages after task completed are unavailable

We are working on implementing Flex with callback and voicemail functions, as documented in: https://www.twilio.com/docs/flex/solutions-library/queued-callback-and-voicemail
Its quite close to what we want, but we would like to be able to access voicemail messages even after an agent handled the task, and the task was completed. I can't seem to find where those recordings can be available from?
In that plugin, the voicemail audio URL is attached to a Task's attributes. According to the TaskRouter documentation on the lifecycle of a Task, once a Task has reached a terminal state (canceled or completed) it is deleted 5 minutes later).
So, you cannot retrieve the voicemail URL from the task.
Call recordings are available through the Twilio REST API though. If you wanted to build a page in Flex that listed the call recordings that have been left as part of this workflow, you could, for example, fetch the recordings from the API (using a Twilio Function) and render them into the Flex page.
That will give you the recordings without any metadata though. If you need to store the metadata further, you will likely need to dig further into the queued callbacks and voicemail plugin to find somewhere to store the data in your own permanent store.

How do I notify users on Slack that aren't in the channel?

What we are trying to do
I am working on automation which posts messages to a Slack channel using Incoming Webhooks on a custom Slack App. The messages mentions people.
What works
We can send a message just fine, it has formatted content, and usernames are correctly resolved using the link-names flag.
What isn't working
The whole point of the notification is to inform a dynamic set of people about something they should care about. The set of people we tag varies hugely (think people who contributed to a pull request) and so not all possible recipients are in the channel these automated messages go to.
We assumed that given the usernames are being directly #-mentioned, they would be notified by Slack. However, two of the users we've tested with and #-mentioned confirm they never received a notification they had been tagged.
This is different to "human" behaviour, where if you #-mention someone in Slack, you get a little message reminding you that person isn't in this channel and offers to invite them or let them know.
As far as we can tell, sending the message programmatically is doing the equivalent of "Do nothing" in the picture above. I want to do either of the other two options, preferably "Let them know".
How can I notify people they've been mentioned? I've looked at all the API documentation and nothing discusses notifying users who aren't in the channel that they are mentioned.
This can't be an uncommon issue.... right?
Notes:
We aren't directly calling chat.postMessage, it's just the only documentation on link_names I could find to link to. We are using Incoming Webhooks, which has minimal documentation on the parameters - it seems to be the same as chat.postMessage.
We would prefer not to move off Incoming Webhooks, but we can do a custom integration with the API if we have to.
You need to invite the user to the channel first, using the Python client that's:
client.channels_invite(
channel=channel_id,
user=user_id
)

Add song to playing queue in Spotify Desktop

I'm trying to queue a song to Spotify Desktop (Windows 8.1) making use of Spotify Remote Control Bridge. I want that song to be appended after the current playing track.
Due to the restrictions Spotify applies to this API, there's no public documentation and I can't get in contact with their developers. This is one of the posts I've been following to understand how this API works: https://medium.com/#b3ngr33ni3r/hijacking-spotify-web-control-5014b0a1a360
I've successfully played a song with https://XXXX.spotilocal.com/remote/play.json?oauth=XXXX&csrf=XXXX&uri=XXXX, but it jumps to playing queue instantly and replaces it entirely.
When I call https://XXXX.spotilocal.com/remote/queue.json?oauth=XXXX&csrf=XXXX&uri=XXXX it always returns "Method not implemented". Do I need a special Oauth token? Or CSRF token?
Just giving an update, you can now add tracks to a queue via a BETA endpoint.
https://developer.spotify.com/documentation/web-api/reference/player/add-to-queue/
I've tested it, and it seems to work as expected.
queue.json endpoint
This endpoint appeared in their js-library, although it never worked and it's, like you said, not implemented. It doesn't matter which arguments you supply.
play.json endpoint
So, this endpoint is more interesting. First of all, in the past you could use the following parameter ?action=queue to add a song to the queue, but sadly this doesn't work with the latest versions for whatever reason. The only thing you currently can supply is the play-context ?context. A context basically tells spotify what to play next (like setting a new queue). So if you want to play a track of an album and simultaneously want the album to finish after the specific song ends, you can supply a ?context=spotify:album:albumid. There is some more information about it in this issue of my library.
Summarizing, you currently can't add songs to the spotify queue, but add your own context which will be used as a future queue
Although it would be nice to know why spotify isn't releasing any documentation about the local-API.

Replying to certain message in Twilio

I am making an event organisation platform. Whenever user creates an event, the candidate gets an email notification as well as sms notification asking whether the suggested time fits or not. The problem is that since it is event organisation, there may be more than one occurance of candidate's mobile phone. So I need to have some unique information to identify to which event candidate is responding to.
I have tried identify using Message SID, but then I realised that Message SID is different on reply message.
So my question would be: is there any way to authenticate to which message candidate is replying to?
Hi Twilio developer evangelist here.
Because every message is idempotent, you wouldn't be able to track them just via the call sid. however, there's way to get around that such as passing a code that goes with each message which you can then read, or using cookies.
I think you are probably going to be more successful using cookies, and luckily enough there is an article on twilio's website that describes just how to do that. And because I noticed you're using PHP, I'm pointing you directly to the PHP article on tracking SMS conversations.
Hope this helps you

Sending and SMS from your computer

There is a ton of data on this subject where you simply take the phone-number+#mobile-carrier.com and send a message, that is not what I am looking to do.
I want to send an SMS, from the command line, in this case, using php, but I would be happy to use bash, and will probably make it into an app or plug in for Safari eventually. Right now, a test case would suit me fine.
I would like to do something like this:
./sms 619-555-1212 "this is the message"
I don't need to receive the message back to the computer, this is a sending only agent.
The criteria that makes all the data I find on this not work, is that I want my correct from: number to show up. I have tried using the email gateway method and changing he from: headers, but it appears they are stripped at the gateway.
I don't mind paying a service to give me certain amount of SMS credits to make this happen. I want to avoid any hardware, where I would have to get a modem or otherwise to connect to my computer.
If I do use a service, something with an example of how to do so within their API would greatly appreciated. I feel this should take me no more than 15 minutes, but I am hours into research and not getting very far with all the little scripts out there that do nothing close to what I want to do.
Thank you very much and sorry that I don't understand this protocol to the best of my ability.
You can send with Twilio using cURL very easily since sending SMS is a simple POST request with three parameters. Here's an example of a bash script that makes calls but could be modified to use the SMS API instead. http://labs.twilio.com/bash/
(I work at Twilio)
you will need sms gateway like http://www.clickatell.com/ for that
You can use any gateway that charges you a few cents for every message sent. They have a simple REST API which requires a very little coding. They even provide you a sample example to get started.

Resources