I feel blocked here. I have written a Twilio autopilot task that is handling an incoming phone call. It is supposed to say something, then transfer the controle of the call to a handler that will transfer the call to an external number. Here is the code:
{
"actions": [
{
"say": "For this question, I will put you in contact with our customer care specialist."
},
{
"handoff": {
"channel": "voice",
"uri": "https://handler.twilio.com/twiml/xxx-my hander id here-xxx"
}
}
]
}
then the url of the handler goes to a twimlbin with this content :
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>+32xxxxx</Dial>
</Response>
The problem is that the task is going directly to the "handoff" action and does not say the text. So the call is transfered to +32xxxxx immediately and the task does not say the text. I have tried to remove the handoff and then the task is saying what it is supposed to say. I really don't know what I am doing wrong. Anybody an idea ?
thx in advance
Twilio evangelist here.
So currently if you include the handoff action in a task, Autopilot ignores all other actions in the task and only executes the handoff. To work around this in your case, you can put a verb in the TwiMLBin you're handing off to before whatever other TwiML you have there now.
So simplify your Task:
{
"actions": [
{
"handoff": {
"channel": "voice",
"uri": "https://handler.twilio.com/twiml/xxx-my hander id here-xxx"
}
}
]
}
And in your TwiML Bin:
<Response>
<Say>For this question, I will put you in contact with our customer care specialist.</Say>
<!-- the rest of your TwiML -->
</Response>
The team knows this isn't ideal and its something they are looking at changing it.
Hope that helps.
Related
I'm sure this is a silly question, but I don't claim to be a developer, just someone with a wide ranging job description 😊
I am following this guide: https://www.twilio.com/blog/forward-voicemail-recordings-to-email
The transcription callback is firing correctly and sending me the email. That's great.
I'm looking to expand this to collect additional information fields through Gather widgets. I have the following being sent to my function:
{
"flow": {
"flow_sid": "FW07e11311d367...f8a0501c05e5108",
"variables": {
"CallerName": "Joe Bloggs"
},
"channel": {
"address": "+441...147"
},
"sid": "FN866c64beb9...f5bf349fa19ad3"
},
"widgets": {
"SetCallerNameVar": {
"CallerName": "Joe Bloggs"
},
"GatherVoicemail": {
"Called": "+4414....7",
"Digits": "#",
"RecordingUrl": "https://api.twilio.com/2010-04-01/Accounts/AC5fa2...12c7/Recordings/RE3a1d420de6db...2abb554c04f6",
"CallerCountry": "GB",
"Direction": "inbound",
[...]
I access the other (working) information through the ${event.variable} syntax. However, simply doing ${event.CallerName} results in "undefined". Can anyone advise how to access the CallerName variable that I have set in my flow?
If I was calling the function rather than using a transcription callback, it would be easy to pass the parameter, but doing so would result in duplicate emails per call.
I hope this makes sense and appreciate any advice.
Thank you
Twilio developer evangelist here.
The issue here is that your transcription callback does not have the same context as the Studio Flow, so does not come with all the other data. You can, however, add that context to the request by setting query parameters on the transcription callback URL.
Try setting your transcription callback URL to:
https://your-function-service.twil.io/?CallerName={{flow.variables.CallerName}}
You will then receive the CallerName in the event object.
Just to note, the Transcription Callback URL field does not highlight the liquid variable, but it does get interpolated. There is now an open issue to add the highlighting to this field.
I'm making a twilio autopilot project and I want to use SSML for the responses. Every time I trigger the intent that contains SSML, it crashes without anything showing up in the debugger. Here's what I'm doing:
{
"actions": [
{
"say":"<speak>Hi, how can I help you today?</speak>"
},
{
"listen": true
}
]
}
Please note (if this matters) that I'm using the console for my project.
What am I doing wrong? Is this not how you use SSML for autopilot? I'm not redirecting this to another function or anything fancy.
Thanks for the help!
Twilio Developer Evangelist here.
According to the Voice TwiML docs for SSML (separate from the Autopilot docs at the moment), when you’re using SSML with <Say> you can skip <speak> and insert rest of the SSML inside <Say>.
You could adjust the prosody of the text that is said in a phone call using SSML in your JSON file like this:
{
"actions": [
{
"say": "<prosody rate='fast'>Speech Synthesis Markup Language (SSML) is a W3C specification that allows developers to use XML-based markup language for assisting the generation of synthesized speech.</prosody>"
},
{
"listen": true
}
]
}
Hope this helps!
I'm using Twilio Autopilot with Programmable Voice as Input Channel and I would like to record the entire conversation that the client has with the robot.
Where and how can I do it?
I'm using a twiML bin that redirects to the Autopilot URL.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Redirect method="POST">[autopilot url]</Redirect>
</Response>
Twilio developer evangelist here.
To record the call without the <Record> TwiML verb, you could
Serve with the AP connect verb <Response> <Connect> <Autopilot>...
Use the Call SID received in the response to that and use the call recording controls API to start recording the call.
Alternatively, you could use the Moment package in a Twilio function that is redirected from an Autopilot task.
For the task you want to record user input for, your Autopilot task code may look like this:
{
"actions": [
{
"collect": {
"name": "your-task-name",
"questions": [
{
"question": {
"say": "What's your first name?"
},
"name": "first_name",
"type": "Twilio.FIRST_NAME"
},
{
"question": {
"say": "How many people would you like the reservation to be for?"
},
"name": "number",
"type": "Twilio.NUMBER"
}
],
"on_complete": {
"redirect": "https://your-function-url.twil.io/your-function-name"
}
}
}
]
}
After redirecting to the Twilio Function, you could write some Node.js code with the Moment module that may look like this:
exports.handler = function(context, event, callback) {
const moment = require('moment');
let responseObject = {};
let memory = JSON.parse(event.Memory);
let first_name = memory.twilio.collected_data.your-task-name.answers.first_name.answer || 'to whom it may concern';
let number = memory.twilio.collected_data.your-task-name.answers.number.answer;
let message = "Ok " + first_name + "You said your group is of size " + number + "Thank you for booking with us";
ResponseObject = {
"actions":[
{ "say": { "speech": message } }
]};
callback(null, responseObject);
}
The code above saves the user's answers to each question your Autopilot assistant asks, expecting different types of responses. These Built-in Field Types include numbers, yes or no answers, dates, times, first names, last names, emails, months, US states, countries, cities, days of the week, currencies, languages, and more. You can also keep track of the question the Autopilot assistant asks in each Autopilot task.
There's more details in this Deep Table tutorial and this Facebook Messenger bot blog post (different communication platform, same code to parse user input.) Hope this helps!
When we ask a user a question that requires letter & numbers in response (voice / on phone), the system always misinterprets what the user says. For example, if they response "ABC123" twilio will send us "Hey Be See one two three". Which when planning on using the response to verify the user via API, makes it unusable.
This is using the Twilio control panel.
Searched and tried different data types at Twilio. Can't find any way, though seems like it'd be a very common thing.
{
"question": "What is your code ?",
"name": "Code"
}
Input is: "ABC123"
Output should be "ABC123"
Output comes out as "Hey Be See one two three"
Twilio developer evangelist here.
That is a known issue :( The alphanumeric field type that would be the way to handle these is on the product roadmap.
Maybe try using the Gather verb in the meantime? Hope this helps <3
You could use it in a Twilio Function and connect it to Autopilot by redirecting to the Function like so:
"on_complete": {
"redirect": {
"method": "POST",
"uri": "https://replace-with-your-function-url.twil.io/example-autopilot"
}
}
I call my mailbox using REST calls to MSGraph:
GET https://graph.microsoft.com/v1.0/me/mailfolders/inbox/messages
As expected I receive a Json with my mails.
To play with a specific mail (move, delete,forward, ...) I saw that the API should be called like
POST me/messages/{id}/forward
I can't target the message if I provide the value of the id field that I get from the JSon. Where to find the correct {id} that I should use?
my result is like the example at https://developer.microsoft.com/en-us/graph/graph-explorer see id: field when calling GET my mails.
Thanks
The id from JSON is OK. what you missing is you have not set the post conent for move/forward.
If you use the forward API, you should set the post content like below:
{
"Comment": "FYI",
"ToRecipients": [
{
"EmailAddress": {
"Address": "XXX#XXX.onmicrosoft.com"
}
}
]
}
This is the worked forward url for me(you can implement the move/delete like this too):
https://graph.microsoft.com/v1.0/me/messages/AAMkAGNjZTcyZDJmLTkzMjYtNGQwNi05Y2UxLTc5NDk0NjEwNjJjMABGAAAAAAAUYpVLVYiKTINMO3MZR0H5BwB3NF3PTyl5QIQd59edwRO9AAAAAAEMAAB3NF3PTyl5QIQd59edwRO9AAApBI9fAAA=/forward
For information please see:
https://learn.microsoft.com/en-us/previous-versions/office/office-365-api/api/version-2.0/mail-rest-operations#ForwardDirectly