Using enhanced speechResult for </Gather> verb in studio - twilio

There is no option to turn on enhanced option for Speech recognition Result in Studio widgets.
In that case,I guess we have to use twiml redirect to another twiml or Run functuion widgets.
But,if we used that ,how will we return back to studio?
using twiml.redirect and ?FlowEvent=return, with this way?
But where should we use this url to get back to studio?
twiml.gather({action:'webhook.twil.io/AC..../FW...xx?FlowEvent=return'
enhanced:true} ,'Hi say your query');
But,this actually doesnt return back to studio.
Or should we put url of another function in action and redirect from that function to studio?

Twilio developer evangelist here.
When you redirect out of a Studio flow to use raw TwiML you should do so using the TwiML Redirect widget.
To handle returning control to Studio, you need to specify a <Redirect> to the Studio Webhook URL and append ?FlowEvent=return. Any additional parameters specified in the return URL will be injected into the Studio context and addressable via Liquid template variables.
Example:
<Response>
<Say>Returning you back to the Studio Flow.</Say>
<Redirect>https://webhooks.twilio.com/v1/Accounts/{AccountSid}/Flows/{FlowSid}?FlowEvent=return&foo=bar</Redirect>
</Response>

You are missing the input attribute:
Try:
twiml.gather({
enhanced: 'true',
action: 'https://webhooks.twilio.com/v1/Accounts/AC.../Flows/FW...?FlowEvent=return',
input: 'speech'
}).say('Please say something so enhanced gather can collect and return to Studio');

Related

Setting dynamic voice attribute inside TwiML Bin from Twilio Studio via TwiML Redirect

I'm trying to use a variable from a Studio Flow to set the type of voice to be used by a gather input interaction generated by a TwiML Bin, but when I attempt to reference the variable as the definition of the voice attribute I get a syntax error. I know that the {{VoiceEnglish}} variable reference works correctly since it will say the correct value if I put it inside of the Say tags, but is there no way to use it for any attributes? Example of what I would like to work is below:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather input="dtmf" timeout="15" numDigits="1" action="https://webhooks.twilio.com/v1/Accounts/[AccountSID]/Flows/[FlowSId}?FlowEvent=return" method="GET">
<Say voice="{{VoiceEnglish}}" language="en-US">English verbiage here</Say>
<Say voice="{{VoiceSpanish}}" language="es-MX">Spanish verbiage here</Say>
</Gather>
</Response>
I think that the TwiML syntax is reported as invalid because it cannot tell that the result of {{VoiceEnglish}} or {{VoiceSpanish}} will be a valid voice.
You are able to to save the TwiML Bin as long as you agree to the modal:
Once you save it, you can use it in your Studio Flow as long as you provide valid VoiceEnglish and VoiceSpanish parameters in the redirect URL.

Run a flow from another flow in Twilio

How can I run a flow from another flow in Twilio Studio Flow?
Help with defining the To and From HTTP parameters:
I am a beginner in programming so I am failing to understand the brief notes given in support docs, namely specifying HTTP additional parameters for "To" and "From".
Additional details from comment:
I am trying to run REST API triggered Flow B from primary Flow A by using an http request widget in Flow A in the format below: (as suggested in a similar problem posted on this portal) Widget: HTTP Request [ACCOUNT_SID:AUTH_TOKEN#studio.twilio.com/v1/Flows/THE_OTHER_STUDIO_FLOW_SID/Executions][2] Content Type: Form URL Encoded KEY:VALUES To:+1234567890 From:+2773123456 I am getting error 401. I tried to swap the To number with the From number without success
There are 2 ways you can trigger one twilio studio flow from another
Method 1:
Use the TwiML Redirect Widget. Place the widget where you need it and specify the target studio flow URL there. Studio URLs have the following format
https://webhooks.twilio.com/v1/Accounts/{AccountSid}/Flows/{FlowSid}
Method 2:
Do the same as above programmatically. You can send twilio a twiML response such as the one below
let twiml = new Twilio.twiml.VoiceResponse();
if (something) {
twiml.redirect({
method: 'POST'
}, 'https://webhooks.twilio.com/v1/Accounts/{AccountSid}/Flows/{FlowSid1}');
} else {
twiml.redirect({
method: 'POST'
}, 'https://webhooks.twilio.com/v1/Accounts/{AccountSid}/Flows/{FlowSid2}');
}
For more info, check out https://www.twilio.com/docs/voice/twiml/redirect
Assuming you are not trying to bridge the call between the two flows, this should be possible. To simplify:
You have a call come in on Flow A ("Incoming Call" trigger on Flow A).
Flow A executes its logic.
That logic triggers Flow B by calling its REST API endpoint so that it makes a new outbound call ("REST API" trigger on Flow B).
This last thing is the hard part. Make sure you are looking at the docs for the REST API Execution resource. To trigger a new flow, you need to make a POST request which supplies the To and From parameters.
If you are a beginner at programming, it might be helpful for you to start with a separate HTTP client like Postman to start to get familiar with the structure of an HTTP request, and learn the full extent of what is required to successfully make this API request before you start trying to cram it into Studio and automate it.
That said, this request should be possible to do within the Studio Make HTTP Request widget. If you make your content type Application/JSON, you can pass the To/From parameters directly in a JSON-formatted request body, like this:
{
"To": "+19995551234",
"From": "+12345556789"
}
To be perfectly honest, I don't know what the widget means by "Http Parameters". This could be HTTP Headers, URI parameters, or something else. I think the JSON form is clearer.
I came across the same situation. The solution for authentication is to change the url to include AccountSid and AuthToken
https://[AccountSid]:[AuthToken]#studio.twilio.com/v2/Flows/[SID]/Executions
Instead of Application / Json, use Form Parameters. Then add individual parameters below, for To, From, and Parameters​ (JSON string) for other variables.

Twilio Voice API - Use "inline" TwiML instead of XML url when creating outgoing call

I'm using the Twilio Voice API to create an outbound call:
$call = $twilio->calls->create(
"+14155551212", // to
"+15017122661", // from
array(
"url" => "http://demo.twilio.com/docs/voice.xml"
)
);
As you can see, the script used for the call is accessed with the "url" parameter pointing to a XML file.
The XML is hard coded though. Is there a way to write "inline" TwiML inside this create function so I can pass in PHP directly to make the script dynamic? Then I wouldnt be using a hard coded XML file but dynamic PHP instead.
For example, if I have:
$customer_name = $customer['name'];
I'd like to be able to pass this into the script to be read when a listens to the call.
How can I accomplish this?
Twilio developer evangelist here.
There is currently not a way to create a call and directly give it static TwiML to execute.
If you don't want to host static TwiML you could choose to host your TwiML in Twilio's TwiML Bins.
If you want the TwiML to be dynamic, but you don't want to host it yourself, you could use Twilio Functions to respond to your webhook.
Let me know if that helps at all.

twilio api - HTTP Request Split in Studio

How would I 'Split Based On' parsed JSON values from a HTTP Request ?
I know it's in the format 'widgets.MY_WIDGET_NAME.parsed.[parsed variable name]', but there is no way I can get to enter this in the Split condition.
I know that they are being returned because I can add them to a SMS Message Body.
Twilio developer evangelist here.
It's not obvious, and we're looking at redesigning to help with this, but if you start typing in the "Split Based On" widget's drop down box you can enter the format of the variable you want.
Let me know if this helps at all.

Orbeon Form HTTP Service

Does anyone know how to pass parameters to a RESTFUL webservice using the Orbeon HTTP Service?
I have a RESTFUL API at http://localhost/RESTFUL/GETADDRESS/$parameter$.
Sample of the URL is http://localhost/RESTFUL/GETADDRESS/1234
Orbeon HTTP service is unable to pass the parameter to the web service.
The Request Body is configured as <parameter/> and serialization is set to XML.
Could not use HTML Form as it adds a ? to the URL which is not correct.
Anyone has any ideas to get this working?
There is no perfect solution. But try writing the service URL as:
http://localhost/RESTFUL/GETADDRESS/{...expression here...}
where "...expression here..." should be replaced by an XPath expression pointing to the value you would like to pass. For example, if pointing to a control called foo in a section called bar, try:
http://localhost/RESTFUL/GETADDRESS/{/*/bar/foo}
I also added this RFE.

Resources