Sorry in advance for my simple question. I am new in Twilio world and am trying to learn Twilio in more depth. I am working with Twilio Studio. I created a function and used Run Function widget in my flow. Since I want to return back from function to my studio flow, I learnt that it would be possible with TwiML Redirect. I read the TwiML Redirect documentations and figured out how I can use it in my function. But the first and basic step which is creating URL is still unclear for me. My question is how I can create a URL for TwiML Redirect widget. I guess it is so obvious that in every tutorial, this step is skipped.
2 Answers
Twilio developer evangelist here.
If you only want to return TwiML directly from your Function, then you don't need a TwiML redirect. Just use the Run Function widget and in your Function, return TwiML. Once that TwiML completes, the call will return to your Studio Flow.
If you want to do something more complicated involving multiple functions or TwiML then instead of running the function with the Run Function widget, you should redirect to your function using the TwiML Redirect widget. This passes all control of the flow to the Function and leaves you to return control to the Studio flow yourself.
To return the flow, you use a TwiML <Redirect>
and the URL should be the Studio Webhook URL with the parameters ?FlowEvent=return
added. See more on this in the TwiML Redirect Widget docs.