我创建了此VoiceXML代码,要求用户填写一些数据,然后将这些数据存储在数据库中。
当我通过Postman运行代码以模拟请求时,我没有收到任何错误。但是,当我实际运行并调用Python / Django语音应用程序时,一旦我的应用程序到达该部分,我就会收到一个“内部错误”。
VoiceXML输出:
<?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>
如果需要的话,可以保存输入的代码:
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')
如果我希望用户能够通过DTMF填写数字并将该数据存储到我的模型中,我的VoiceXML代码是否正确?还是我错过了一些重要的功能?
编辑:错误日志:
============================================================
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>
答案 0 :(得分:1)
要将结果发布回服务器,您需要使用submit
元素而不是goto
元素。
<submit src="/vxml/InputData/34/8" namelist="DTMF_input" method="post"/>
在VoiceXML specification中查看详细信息。