Jump to: navigation, search

Fetch Data in JSON Format

As the following sample demonstrates, the fetched resource can return data in JSON format. The data can then be parsed by an SCXML session. Note that in this example the result of the parsing is stored in the Target global variable.

Fetched file content: File http://localhost:9090/strategies/01_BASIC/_aux/GetDate.jsp

<%="{\"year\":2008, \"month\":\"December\", \"date\":25}"%>

Root strategy

<scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml"
        xmlns:queue="www.genesyslab.com/modules/queue"
        xmlns:dialog="www.genesyslab.com/modules/dialog"
        xmlns:session="www.genesyslab.com/modules/session"
        initial="initial">
  <script>var date = ""</script>
  <state id="initial">
    <transition event="interaction.added" target="fetch"/>
  </state>
  <state id="fetch">
    <onentry>
      <script>var URI="http://localhost:9090/strategies/01_BASIC/_aux/GetDate.jsp";</script>
      <session:fetch srcexpr="URI" type="'application/json'"/>
    </onentry>
    <transition event="session.fetch.done" target="check">
      <script>date = JSON.parse(_event.data.content);</script>
    </transition>
    <transition event="error.session.fetch" target="error"/>
  </state>
  <state id="check" >
    <transition cond="date.month=='December' && date.date==25" target="routing"/>
    <transition target="error"/>
  </state>
  <state id="routing">
    <onentry>
      <queue:submit priority="5" timeout="20">
        <queue:targets type="dn">
          <queue:target name="'7102'"/>
        </queue:targets>
      </queue:submit>
    </onentry>
    <transition event="queue.submit.done" target="exit">
      <log expr="'DONE'"/>
      <log expr="_genesys.ixn.interactions[0].voice.ani"/>
      <log expr="'DONE'"/>
      <log expr="_event.data.targetselected"/>
    </transition>
    <transition event="error.queue.submit" target="error"/>
  </state>
  <final id="exit"/>
  <final id="error"/>
</scxml>
This page was last edited on September 22, 2017, at 13:06.
Comments or questions about this documentation? Contact us for support!