0

I am creating a project in Studio and also learning about applying custom TwiMl.

I am trying to use a custom TwilML like the following in my studio project :

<Response>
     <Dial record="true" action="record_done">
         <Conference waitUrl="">record</Conference>
     </Dial>
</Response>

I believe there are two ways, one is creating a function and using the 'Run Function' widget and the other would be 'TwiML Redirect'. When I use this TwiML to create a TwiML Bin, it shows invalid syntax. I also don't know how I can apply this TwiML to create a function and how I can apply that function in my studio project.

Any help would be much appreciated.

Update:

I wrote this function:

exports.handler = function(context, event, callback) {
    const VoiceResponse = require('twilio').twiml.VoiceResponse;

    const response = new VoiceResponse();
    const dial = response.dial({record: 'true', action: 'record_done'});
    dial.conference({
        waitUrl: ""
    }, 'record');
    
    console.log(response.toString());
callback(null, response);
};

for the attribute action: 'record_done', I received this error in Twilio debugger: HTTP retrieval failure.

Lili
  • 23
  • 1
  • 8

1 Answers1

1

The action URL is where Twilio goes once the <Dial> completes. Is there an application at that URL you are telling Twilio to go to?

https://baseURL/record_done

If not, then that explains the HTTP retrieval failure.

action

enter image description here

Alan
  • 10,465
  • 2
  • 8
  • 9
  • Thank you for your response. I am using Twilio Studio. How can I get the URL of the next widget after the 'Run Function' Widget, so I put it as an action URL? the next widget after this function would be a recording widget. – Lili Jan 01 '21 at 17:57
  • You cannot use the `Run Function Widget` and then return back to the Studio Flow if you return TwiML. Instead, use the `TwiML Redirect Widget` to execute your function and then the action URL should be able to indicate a return to the Studio Flow. (Returning Control to Studio) - https://www.twilio.com/docs/studio/widget-library/twiml-redirect. – Alan Jan 01 '21 at 20:55