twiliotwilio-twimltwilio-studio

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>

Solution

  • 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:

    A modal that says the TwiML Bin contains invalid TwiML and asks if you are sure you want to save it. The options are cancel or save.

    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.