2

I have created this VoiceXML code to ask the user to fill in some data, which is then supposed to be stored in the database.

When I run the code through Postman to simulate the request, I don't get any errors back. But when I actually run and call my Python/Django voice application I get an 'internal error' back once my application reaches that part.

The VoiceXML output:

<?xml version="1.0" encoding="UTF-8"?>
<!--- <vxml version = "2.1" > -->
<!DOCTYPE vxml SYSTEM "http://www.w3.org/TR/voicexml21/vxml.dtd">
<vxml xmlns="http://www.w3.org/2001/vxml"
  version="2.1"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.w3.org/2001/vxml
  http://www.w3.org/TR/2007/REC-voicexml21-20070619/vxml.xsd">
    <!---<property name="inputmodes" value="dtmf" /> -->
    <!-- Kasadaka VoiceXML File -->
    <form id="input_form">
        <property name="inputmodes" value="dtmf" />
        <property name="interdigittimeout" value="2s"/>
        <property name="timeout" value="4s"/>
        <property name="termchar" value="#" />
        <field name="DTMF_input" type="digits?maxlength=5">
            <prompt>
                <audio src="/uploads/petrichor_here_you_can_fill_in_your_farmer_id_en_QL7Xu6T.wav"/>
            </prompt>
        </field>
        <block>
            <prompt>
                <audio src="/uploads/petrichor_thank_you_for_your_input_en_rFaZyF5.wav"/>
            </prompt>
            <filled namelist="DTMF_input">
                <submit src=" /vxml/InputData/34/18" namelist="DTMF_input" method="post"/>
            </filled>
        </block>
    </form>
</vxml>

And if needed, the code that is supposed to save the input:

def InputData(request, element_id, session_id):
    input_element = get_object_or_404(InputData_model, pk=element_id)
    voice_service = input_element.service
    session = lookup_or_create_session(voice_service, session_id)


    if request.method == "POST":
        session = get_object_or_404(CallSession, pk=session_id)

        value = 'DTMF_input'

        result = UserInput()

        result.session = session

        result.category = input_element.input_category 

        result.save()

        return redirect(request.POST['redirect'])

    session.record_step(input_element)
    context = input_generate_context(input_element, session)

    context['url'] = request.get_full_path(False)

    return render(request, 'input.xml', context, content_type='text/xml')

Is my VoiceXML code correct if I want the user to be able to fill in numbers through DTMF and then store that data into my model? Or am I missing something important for it to work?

EDIT: Error Logs:

============================================================
Error Summary
============================================================
An error occurred while executing the following dialog.

Initial URL1:               http://petrichor-rain-system.herokuapp.com/vxml/start/3
Initial URL2:               null
Initial URL3:               null
Current URL:                /vxml/choice/35/26
Calling Number (ANI):       447520631888
Called Number (DNIS):       9991494860
Redirecting Number (RDNIS): ""
State:                      hello-and-welcome
VoiceXML Browser Version:   16.0.25.88606
Date/Time:                  2019/4/18  10:4:29.387

VoiceException:
    error.badfetch
    Could not compile document: http://petrichor-rain-system.herokuapp.com/vxml/InputData/33/26


Dialog stack trace:
    State (Dialog)          URL (Document)
    --------------          ------------------------------
    hello-and-welcome       http://petrichor-rain-system.herokuapp.com/vxml/choice/35/26




============================================================
Current Document
============================================================

<?xml version="1.0" encoding="UTF-8"?>
<!--- <vxml version = "2.1" > -->
<!DOCTYPE vxml SYSTEM "http://www.w3.org/TR/voicexml21/vxml.dtd">
<vxml xmlns="http://www.w3.org/2001/vxml"
  version="2.1"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.w3.org/2001/vxml
  http://www.w3.org/TR/2007/REC-voicexml21-20070619/vxml.xsd">

<meta name="maintainer" content="email" />

<property name="inputmodes" value="dtmf" />

<!-- Kasadaka VoiceXML File -->




<form  id="hello-and-welcome">
        <field name="choice">
                <prompt>
                        <audio src="/uploads/petrichor_hello_welcome_en_AwoXmq3.wav"/>

                                <audio src="/uploads/pre_choice_option_en.wav"/>
                                <audio src="/uploads/petrichor_press_one_to_listen_to_explanation_en_L6iqUHW.wav"/>
                                <audio src="/uploads/post_choice_option_en.wav"/>
                        <audio src="/uploads/1_en.wav"/>

                                <audio src="/uploads/pre_choice_option_en.wav"/>
                                <audio src="/uploads/petrichor_press_two_to_fill_in_collected_data_en_zXRGSby.wav"/>
                                <audio src="/uploads/post_choice_option_en.wav"/>
                        <audio src="/uploads/2_en.wav"/>

                                <audio src="/uploads/pre_choice_option_en.wav"/>
                                <audio src="/uploads/petrichor_press_three_to_stop_the_call_en_bOL0PDC.wav"/>
                                <audio src="/uploads/post_choice_option_en.wav"/>
                        <audio src="/uploads/3_en.wav"/>

</prompt>


<grammar xml:lang="en-US" root = "MYRULE" mode="dtmf">
      <rule id="MYRULE" scope = "public">
        <one-of>

            <item>1</item>

            <item>2</item>

            <item>3</item>

        </one-of>
       </rule>
</grammar>


<filled>


      <if cond="choice == '1'">

      <goto next="/vxml/message/18/26"/>



      <elseif cond="choice == '2'" />
      <goto next="/vxml/InputData/33/26"/>



      <elseif cond="choice == '3'" />
      <goto next="/vxml/choice/22/26"/>




    <else/>
    </if>
  </filled>

</field>
</form>


</vxml>
Natasja
  • 97
  • 1
  • 2
  • 9
  • Can you please post the resulting VoiceXML (not the template)? What VoiceXML platform are you testing against? – gawi Apr 13 '19 at 17:41
  • 1
    @gawi I have changed the VoiceXML to the resulting one. I am using Voxeo to call and test my application. – Natasja Apr 13 '19 at 18:00

1 Answers1

1

To post the results back to the server, you need to use the submit element and not the goto element.

<submit src="/vxml/InputData/34/8" namelist="DTMF_input" method="post"/>

See details in the VoiceXML specification.

gawi
  • 13,940
  • 7
  • 42
  • 78
  • Thank you, I have changed the with your proposed solution, but when I call my application I still get an internal error saying the VoiceXML cannot be compiled. – Natasja Apr 14 '19 at 17:41
  • Were the results sent to the server? If yes, then the problem is with resulting page (input.xml). Otherwise, it's a problem with the document you have pasted here. Ideally, you should have a more detailed error message. Is there a way to get the actual logs from Voxeo? – gawi Apr 14 '19 at 18:05
  • No the results weren't sent to the server because I get the error before I have the chance to fill something in. Voxeo does offer a debugger, but when I turn that on and make the call it just stays empty. – Natasja Apr 14 '19 at 18:25
  • You should try to remove the grammar element altogether. It is not legal to put a grammar as a child of vxml element. Also, it is not necessary if you specify type="digits" – gawi Apr 14 '19 at 19:55
  • I have removed the grammar element, but I still get the same error. I also think that I missed the command when submitting the input, so I added that as well. Unfortunately, both didn't help solve the error. – Natasja Apr 15 '19 at 09:59
  • When used, the `filled` element should be a child of the `form` or the `field`. You must obtain the Voxeo call logs to see the actual error details. – gawi Apr 15 '19 at 10:17
  • I have altered my code, but still, I receive the same error. I was able to get some error logs, but they don't give me much more information. – Natasja Apr 18 '19 at 10:20