Sono nuovo in voiceXML e mi chiedo come leggere un valore restituito dal server dopo la pubblicazione. Voglio voiceXML per leggere la risposta del server. According to voiceXML documentation, ho capito che il risultato dovrebbe essere in XML.rendere voiceXML per leggere il risultato restituito dal server
Ecco il mio codice Node.JS/express.js che riceve il risultato:
app.post("/getData", function (req, res) {
console.log(JSON.stringify(req.body));
res.header('Content-Type','text/xml').send('<?xml version="1.0" ?> <vxml version="2.0"> <block> <prompt> The time in Milwaukee is 10 </prompt> </block> </vxml>');
});
Ecco lo screenshot mostra che sto ricevendo con successo il contenuto pubblicato:
Ecco lo screenshot che mostra che sto inviando il risultato XML:
Ecco il mio file VoiceXML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN" "http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml xmlns="http://www.w3.org/2001/vxml" xmlns:bevocal="http://www.bevocal.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
<form scope="dialog">
<field name="name" modal="false">
<grammar src="grammars.grammar#Names"/>
<prompt>Whats your name?</prompt>
<filled>
<prompt>Hello <value expr="name"/>
</prompt>
</filled>
</field>
<field name="city" modal="false">
<grammar src="grammars.grammar#Cities"/>
<prompt>What city are you from?</prompt>
<filled>
<prompt>You are from <value expr="city"/>
</prompt>
</filled>
</field>
<field name="country" modal="false">
<grammar src="grammars.grammar#Countries"/>
<prompt>What country are you from?</prompt>
<filled>
<prompt>You are from <value expr="country"/>
</prompt>
</filled>
</field>
<field name="cityTime">
<prompt>
What city would you like the time for?
</prompt>
<grammar type="application/x-nuance-gsl">
[denver (san francisco) ]
</grammar>
</field>
<field name="formatTime">
<prompt>
Twelve hour or twenty four hour clock?
</prompt>
<grammar type="application/x-nuance-gsl">
[[twelve (twenty four)] ?hour]
</grammar>
</field>
<block>
<submit next="http://65.29.170.122/getData" method="post" namelist="name city country cityTime formatTime" />
</block>
</form>
</vxml>