Debugging VoiceXML Applications with Fiddler

I was working on adding the ability to record user input in VoiceModel when I ran into an issue with the syntax of the VoiceXML that was returned to the IVR.  I was testing the changes using Voxeo's Prophecy IVR and the logs told me what line the issue was on but I could not understand why my application was generating the VoiceXML in question and I could not see VoiceXML document to verify what was going on.  My usual step for troubleshooting issues like this is to take the URL from the Prophecy log associated with the issue and put it in a web browser to see what the IVR is working with.  But in this case the IVR was doing a POST and a web browser can only perform GET operations.

After you create a user recording in VoiceXML using the record element you need to send the audio file from the IVR to you application using the submit element in order to save it, as shown below.  The recording does not do you much good if you leave it on the IVR.

<submit expr="Record/SaveRecording" method="post" namelist="myRecording" enctype="multipart/form-data"/>

In order to send the audio file you must perform a POST and therein lies my dilemma.  How can I view and test the VoiceXML returned from the POST operation.  I had used Fiddler before to test RESTful API's that required POST operations and I thought this would be the right tool for the job.  Because VoiceModel uses ASP.NET MVC this method will also work for troubleshooting web applications and web services.

To get started you will need to download Fiddler 2 from here and install it.  After Fiddler is installed just start it up and it will start capturing HTTP traffic immediately.  I was hoping that Fiddler would capture the traffic between my VoiceXML application and the IVR as I ran through the voice application, but that did not work.  Fiddler will not pick up traffic if you use "localhost" as the server name.  Usually this is easily corrected by using "" for the IP address of the server instead.  But even though I setup the Prophecy IVR to use this IP address it still did not show up in Fiddler.  Not to worry, there is another technique to get the information that we want.

I opened up a web browser and put in the URL that the IVR was using for the POST.  This will fail in the MVC ASP.NET application because the Controller is expecting a POST to route to the correct method.  The method in the Controller is adorned with the [HttpPostattribute.  You will get a 404 Not Found error as shown below in the Response Header section of Fiddler.

Right click on the original request in the left-hand pane and select Replay/Reissue and Edit from the pop-up menu.  This will allow you to edit the request before it is sent again.  Edit the request header in the top right pane and change the GET to POST.  Now click on the button that says Run to Completion. This will resend the request as a POST this time and you will be able to view the response in the lower right pane.  Just click on the TextView tab to view the VoiceXML that is returned.  Now you can test generation of the VoiceXML document by reissuing the POST request by right clicking on it and this time selecting Replay/Reissue Requests.  If you are running the application in Visual Studio Debugger you can even step through the code to see what is going on.

This technique allowed me to easily fix the issue in the new record functionality in VoiceModel.  After some additional testing I should have it released soon on CodePlex. I recommend making Fiddler part of your toolbox.


Popular posts from this blog

Customizing Claims for Authorization in ASP.NET Core 2.0

Using Claims in ASP.NET Identity

Adding Email Confirmation to ASP.NET Identity in MVC 5