2012-10-04 4 views
0

시작 및 끝 번호를 사용하여 PHP 사용 여부에 관계없이 VXML의 배열에 입력을 저장하는 필드를 반복 할 수 있습니까?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 개의 프롬프트 (비즈니스 요구 사항에 따라 다시 설계하라고 요구하지 않음)
  • 솔루션은 hangup 이벤트를 지원해야하므로 연결이 중간에 끊어지면 수집 된 결과를 저장할 수 있습니다.
  • 공급 업체 - 독립적 인 VoiceXML 2.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> 

이 당신에게 루프를 처리하고 그 결과를 제출하는 방법에 대한 좋은 아이디어를 제공합니다. 나는 오류 처리를 포함하지 않았다.