Jump to: navigation, search

Route to Agent Using Statistic

The following SCXML strategy routes an interaction to one of two agents based on a statistic. It requests the statistic value first, waits for this value to become available using a special state called delay, and then uses this value for routing.

<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:statistic="www.genesyslab.com/modules/statistic" 
        initial="initial">
  <state id="initial">
<!--
    <transition event="interaction.added" target="statistics"/>
-->
    <transition event="interaction.added" target="subscribe"/>
  </state>
<!--
  <state id="routing">
    <onentry>
      <queue:submit orderstat="'StatTimeInReadyState'" ordertype="'max'" priority="5" clearontimeout="true" timeout="0">
        <queue:targets type="agent">
          <queue:target name="'az'"/> 
          <queue:target name="'bz'"/> 
        </queue:targets>
      </queue:submit>
    </onentry>
    
    <transition event="queue.submit.done" target="error"/>
    <transition event="error.queue.submit" target="delay"/>
  </state>
-->
<!--
  <state id="statistics">
    <onentry>
      <script>
        var t1 = _genesys.statistic.sData('az@.A', 'StatTimeInReadyState');
        var t2 = _genesys.statistic.sData('bz@.A', 'StatTimeInReadyState');
      </script>
    </onentry>
    
    <transition target="delay"/>
  </state>
  
  <state id="delay">
    <onentry>
      <send event="'delay'" target="_sessionid" targettype="'scxml'" delay="'2s'"/>
    </onentry>
    <transition event="delay" target="routing"/>
  </state>
-->
  <state id="subscribe">
    <onentry>
      <statistic:subscribe object="'az@.A'" statistic="'StatTimeInReadyState'" interval="0"/>
      <statistic:subscribe object="'bz@.A'" statistic="'StatTimeInReadyState'" interval="0"/>
    </onentry>
    
    <transition event="statistic.subscribe.done" target="delay"/>
    <transition event="error.statistic.subscribe" target="error"/>
  </state>
  <state id="delay">
    <onentry>
      <send event="'delay'" target="_sessionid" targettype="'scxml'" delay="'2s'"/>
    </onentry>
    <transition event="delay" target="routing"/>
  </state>
  <state id="routing">
    <onentry>
      <queue:submit orderstat="'StatTimeInReadyState'" ordertype="'max'" priority="5" timeout="20">
        <queue:targets type="agent">
          <queue:target name="'az'"/> 
          <queue:target name="'bz'"/> 
        </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 August 14, 2014, at 20:21.
Comments or questions about this documentation? Contact us for support!