Example of a TalkML Application

TalkML Travel Desk

This is a simple application for booking a flight.

<talkml first="start">
  <dialog name="start">
    <say>Welcome to the TalkML travel desk.</say>
    <act next="destination"/>
  </dialog>

  <dialog name="destination">
    <say>Which city to you want to fly to?</say>
    <listen response="destination">
      "San Francisco"|"New York"|"Seattle"|"Los Angeles"|"Boston"
    </listen>
    <error next="retry">
      Sorry, I did not understand. You can choose
      between: San Francisco, New York,
      Seattle, Los Angeles or Boston.
    </error>
    <act next="when"/>
  </dialog>

  <dialog name="when">
    <say>
      Which day do you want to travel to <var name="destination"/>?
    </say>
    <listen grammar="date"/>
    <error next="retry">
       Sorry, I did not understand. You can refer to
       a day such as <em>next Friday</em>
       or give the date such as <em>May 13</em>
    </error>
    <act next="origin"/>
  </dialog>

  <dialog name="origin">
    <say>Which airport are you leaving from?</say>
    <listen response="origin">
      "Bristol"|"Heathrow"|"Gatwick"|"Stansted"
    </listen>
    <error next="retry">
      Sorry, I did not understand. You can choose to
      fly from: Bristol, Heathrow, Gatwick or Stansted
    </error>
    <act on="origin=Gatwick" next="offer"/>
    <act next="airline"/>
  </dialog>

  <dialog name="offer">
     <say on="errors=0">
       This week Virgin is offering free rental
       cars when you fly first class from Gatwick.
       Would you like to take advantage of this?
     </say>
     <listen grammar="confirm"/>
     <error next="retry">
       Sorry, I did not understand. Do you want to
       take advantage of Virgin's offer, yes or no?
     </error>
     <act on="result=true"
            set="airline='Virgin'"
            next="finish"/>
     <!-- otherwise ask for airline -->
     <act next="airline"/>
  </dialog>

  <dialog name="airline">
     <say>Which airline do you prefer?</say>
     <listen response="airline">
        "United"|"British Airways"|"Virgin"
     </listen>
     <error next="retry">
       Sorry, I did not understand. You can choose to
       fly with: United, British Airways or Virgin
     </error>
     <act next="finish"/>
  </dialog>

  <dialog name="finish">
    <say>
      You have chosen to fly <var name="airline"/>
      to <var name="destination"/> leaving on
      <var name="date"/> from <var name="origin"/>.
      Thanks for using the TalkML travel service.
    </say>
  </dialog>
</talkml>