0

Using the TwiML Voice: verb to collect a voice message, save it and transcribe it.

I've got a PHP file to generate an email and the end to end seems to be working fine.

My problem is that, in an early step, I collect an access code from the caller which does a lookup for the customer info. I use that info in a subsequent step to personalize the experience.

Now I want to send the collected info into the transcribeCallback definition so I can include it in the email that alerts pagerduty to call the customer back. However, when I add additional query strings on the url for transcribeCallback it generates an error.

<Record action="/v2/goodbye.xml" timeout="15" transcribe="true" transcribeCallback="/v2/processtrans.php"/>

The email works and I have all the default values like TranscriptionText and TranscriptionUrl, but I don't know how to get access to my own values like customer code, name, email, etc.

Before I started using the PHP handlers, I used the built-in twimlets setup:

<Record action="/goodbye.xml" timeout="15" transcribe="true" transcribeCallback="http://twimlets.com/voicemail?Email=mysupport@pagerduty.com"/>
Chrisjx
  • 113
  • 1
  • 1
  • 9

2 Answers2

1

ecorvo's answer is what I was looking for because it confirms that I can, in fact, add query string parameters to the transcribeCallback.

But I had to resolve 2 problems...

The twilio approach I am using requires a series of XML files, each one cascading to another through the action attribute which define what is to be said, recorded, etc. I am dynamically generating these xml files in PHP.

First problem - the XML was being rejected with an error indicating a missing ";"/semi-colon. This turned out to be caused by the "&" separator between the first and second parameters. So I changed & to &amp; and that fixed that. https://stackoverflow.com/a/23422397/534453

Second problem - I needed to urlencode the parameters and then urldecode in the next PHP script.

My PHP script to build the twiml record verb string looks like this:

'<Record action="/intl-v2/goodbye.xml" timeout="15" transcribeCallback="/intl-v2/processtrans.php?acode='.urlencode($accesscode).'&amp;compname='.urlencode($compname).'"/>

Hope this helps...

Community
  • 1
  • 1
Chrisjx
  • 113
  • 1
  • 1
  • 9
0

You should be able to pass the values as query string parameters like this:

<Record action="/v2/goodbye.xml" timeout="15" transcribe="true" transcribeCallback="/v2/processtrans.php?param1=firstParam&param2=secondParam"/>
ecorvo
  • 3,559
  • 4
  • 24
  • 35