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!
Related
I have a Dialogflow Bot that is integrated with a Twilio phone number. I am trying to get Twilio to pass the "from" number that initiates an interaction to Dialogflow, so I can later log it in a fulfillment.
I put this in Fulfillment:
function reschedule(agent) {
const OriginalDetectIntentRequest = agent.parameters.OriginalDetectIntentRequest;
then: axios.post('https://sheetdb.io/api/v1/q0te84lfo1aal?sheet=Appointments', {
"data": {
"student": student,
"to_date": to_date,
"from_date": from_date,
"created": new Date(),
"OriginalDetectIntentRequest" : OriginalDetectIntentRequest,
}
});
Everything posts except the OriginalDetectIntentRequest.
Here's the reference: https://cloud.google.com/dialogflow/es/docs/reference/rest/v2/OriginalDetectIntentRequest
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 working with Twilio programmable video and I'd like to integrate it with TaskRouter.
Currently I can create custom tasks with a POST request to:
https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSID}/Tasks/
Yet regardless of what I put into the request body, the task shows up as "Anonymous Task, Reserved".
Is this an issue of formatting? I'd ideally like it to say something along the lines of "Incoming video request" with the customer name in the task-bar similar to how chat tasks look.
Here's the dummy data I tried passing in to no avail. I've tried a few different ways:
{
"attributes": {
"type": "video",
"contact": "+17777777777",
"customer-value": "gold",
"task-reason": "support",
"callSid": "CA42ed11...",
"name": "Joe",
"customer_name": "Joe"
}
"name": "Joe",
"customer_name": "Joe"
}
None of this data is passed through to the task. Any help would be appreciated.
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 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.