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!
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.
When using the new Studio API to import and export Studio flow JSON everything transfers correctly, however when importing from another account there are issues translating functions.
The service and environment sid can be replaced for the entire flow. While not ideal the process could however be automated. The real problem is with the function sid .Finding the function_sid would need to be manual or an api call to retrieve making this a more complicated process.
Currently the other option is to open the flow in the UI and mannual select the correct function. Is there a better way to do this?
Here is an example of the area of JSON that is an issue.
"properties": {
"service_sid": "<Your-service-sid-unique-to-account>",
"environment_sid": "<Your-environment-sid-unique-to-account/service>",
"offset": {
"x": -1230,
"y": -7330
},
"function_sid": "<Your-function-sid-unique-to-function>",
"parameters": [
{
"value": "{{trigger.message.From}}",
"key": "from"
}
],
"url": "https://<function-endpoint>.twil.io/data/<function>"
}
From one of my collegues:
I would set the FQDN of the Twilio Function using liquid syntax in the Run Function Widget, that way the customer only has to update their Set Variables Widget in the case of having multiple function calls
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"
}
}
Imagine you are working under following circumstances:
You have REST API modules with API documentation generated into swagger-ui.html
Possible HTTP status codes for endpoints are documented well via io.swagger.annotations.* on controller method level for each endpoint.
In case of some error state (4XX or 5XX) application replies with ErrorResponseDTO with structure like
"ErrorResponseDTO": {
"type": "object",
"properties": {
"errorCode": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
Application have tens of errorCodes (within range like 1 - XX and please consider them as a legacy definiton without an easy way to change them).
List of errorCodes is relevant for the whole application so you prefer to keep their definiton list/table in overall API documentation rather then maintaining errorCodes definiton for each API endpoint separately.
Now you are looking for an effective way how to document these application error codes into API contract.
The approach of including a list of errorCodes with codes description into generated swagger-ui.html seems like a better way to keep API documentation up to date instead of having static and handwritten codes definition table attached in Markdown format in some Readme file.
Would you please have any recommendation how to document various codes which your applications produce?
Do you follow some specific good practice in this topic?
Thank you in advance.
Meanwhile within a small internal dev team and with frequent API extensions there can be used generated swagger-ui with included error codes:
#Bean
public Docket swaggerSettings() {
ApiSelectorBuilder builder = new Docket(DocumentationType.SWAGGER_2)
.apiInfo(
new ApiInfoBuilder()
.title("Response errorCodes table")
.description(RestResponse.generateErrorsDocumentation().toString())
.build()
)
...
.select();
return builder.apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
.paths(PathSelectors.any())
.build()
.useDefaultResponseMessages(false);
}
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.