0

開始番号と終了番号を使用してフィールドをループし、PHPの有無にかかわらずVXMLの配列への入力を保存するにはどうすればよいですか?

疑似コードは次のようになります。

get startNo from caller
get endNo from caller
loop i from startNo to endNo
   audio prompt 'prompt' + i + '.wav'
   save input to results[i]
end loop
save results to database at end of loop or upon hangup

開始番号と終了番号を取得する方法とデータベースに保存する方法を知っています。それは私が確信していないループです。

要件/その他の注意事項:

  • VXMLとPHPを組み合わせても問題ありませんが、エディターでコード補完を維持するために、ほとんどのVXMLを.VXMLファイルに保持したいと思います。
  • 最大50のプロンプトが表示される可能性があります(ビジネスで必要な場合は、再設計を求めないでください)
  • ソリューションはハングアップイベントをサポートする必要があるため、接続が途中で失われた場合でも、収集された結果を保存できます。
  • ベンダーに依存しない、VoiceXML2.1準拠
4

1 に答える 1

3

VXMLは次のようになります。

<?xml version="1.0" encoding="UTF-8"?> 
<vxml version = "2.1"> 

<var name="currNo" expr="startNo"/>
<var name="userResponse"/>

<form id="getUserInput"> 

   <field name="F_1" cond="currNo <= endNo"> 
     <grammar srcexpr="currNo + '.xml'" type="application/grammar-xml"/>
     <prompt>
       <audio expr="currNo + '.wav'"/>
     </prompt>
   </field>
   <filled>
      <assign name="userReponse" expr="F_1"/>
      <goto next="#handleResponse"/>
    </filled>
</form>

<form id="handleResponse">
   <block>
      <!-- Send each result to PHP app as you get them -->
      <!-- This way you will not loose any result on error or hangup -->
      <!-- Assumes you have some user ID to associate the result with -->
      <submit next="handleUserResponse.php" namelist="userId userResponse"/>
      <!-- Increment counter -->
      <assign name="currNo" expr="currNo + 1"/>
      <!-- If the counter is greater than endNo then we are done -->
      <if cond="currNo > endNo>
         <submit next="endApplication.vxml"/>
      <!-- Otherwise we loop back to get another response -->
      <else/>
          <goto next="#getUserInput"/>
      </if>
    </block>
</form>
</vxml>

これにより、ループを処理して結果を送信する方法についての良いアイデアが得られます。エラー処理は含まれていません。

于 2012-10-05T13:51:26.290 に答える