Show / Hide Table of Contents

    Custom IVR Template: CE Set SDU Field Value

    For backend IVR flows, it is used to set the value of an SDU field related to this call.

    Note

    The IVR flow operates in a 'backend' manner when a customer call it handles was already queued in Contact Expert, and the flow was triggered because the IVR acted as a virtual 'agent' in the CE queue.

    Template Data Sheet

    Name Minimum Engine version Minimum Designer version
    CESetSDUFieldValue 2.0.8 7.5.0

    Parameters

    Name Description
    m_compsrv Input: Component server URL: eg. http://127.0.0.1/CompSrv/ceoh.comp
    m_sduid Input: CE SDU ID.
    m_fieldname Input: The name of the SDU field to set the value of.
    m_fieldvalue Input: The value of the field.

    Exit Points

    Name Description
    error Failed to set the SDU field value.
    ok SDU field value properly set.

    JSON

    {
      "name": "CESetSDU",
      "type": "template",
      "description": "<b>CESetSDU</b> template:<br/> Set SDU Field",
      "attributes": [
        {
          "name": "id",
          "type": "integer",
          "defaultvalue": "7500"
        }
      ],
      "parameters": [
        {
          "name": "m_compsrv"
        },
        {
          "name": "m_sduid"
        },
        {
          "name": "m_fieldname"
        },
        {
          "name": "m_fieldvalue"
        }
      ],
      "connections": [
        {
          "name": "error"
        },
        {
          "name": "ok"
        }
      ]
    }
    

    XML

    <template name="CESetSDU" id="#ID#" version="1.0">
      <constraints>
        <errors AllAttributesRequired="true" />
        <warnings MinIncomingConnections="1" AllConnectionsRequired="true" />
      </constraints>
      <parameters>
        <parameter id="m_compsrv">
          <![CDATA[#M_COMPSRV#]]>
        </parameter>
        <parameter id="m_sduid">
          <![CDATA[#M_SDUID#]]>
        </parameter>
        <parameter id="m_fieldname">
          <![CDATA[#M_FIELDNAME#]]>
        </parameter>
        <parameter id="m_fieldvalue">
          <![CDATA[#M_FIELDVALUE#]]>
        </parameter>
      </parameters>
      <connections namedoutputs="true">
        <connection name="error" destination="#ERROR#" />
        <connection name="ok" destination="#OK#" />
      </connections>
      <flow>
        <nodes>
          <script id="30">
            <parameters>
              <parameter id="m_compsrv" type="variable" datatype="string" direction="input">?</parameter>
              <parameter id="m_sduid" type="Variable" datatype="String" direction="input"><![CDATA[?]]></parameter>
              <parameter id="m_fieldname" type="Variable" datatype="String" direction="input"><![CDATA[?]]></parameter>
              <parameter id="m_fieldvalue" type="Variable" datatype="String" direction="input"><![CDATA[?]]></parameter>
            </parameters>
            <connections namedoutputs="true">
              <connection name="ERROR" exitpoint="error" destination="?"/>
              <connection name="OK" exitpoint="ok" destination="?"/>
            </connections>
            <data>
              <![CDATA[
    
    $$nextConnection$$ = 'ERROR';
    var sipTo = '' + headers["TO"]
    var timeout = 10000;
    var mimetype = "application/jsonrequest";
    var chanid = null;
    var campid = null;
    var contactid = null;
    var re = /^.*;ce-chanid=(\d+)[;]*.*$/;
    var match = re.exec(sipTo);
    
    if (match.length == 2) {
    
        chanid = match[1];
        log.debug("Called channel id:" + chanid);
    }
    
    if (chanid != null) {
    
        var compsrvurl = '' + LOCALS['m_compsrv'];
    
        try {
    
            var js = toolkit.getJSonRetriever();
            var req = {};
            req["action"] = "ivrce_setsduvalue";
            req["channel"] = chanid;
            req["sduid"] = '' + LOCALS["m_sduid"];
            var d = {}
            d['' + LOCALS["m_fieldname"]] = '' + LOCALS["m_fieldvalue"]
            req["data"] = d;
    
            var resp = js.postData(compsrvurl, timeout, JSON.stringify(req), mimetype);
    
            if (resp == null) {
    
                log.error("Null response for ivrce_setsduvalue");
            } 
            else {
    
                log.debug("ivrce_setsduvalue response:" + resp);
                var resp = JSON.parse(resp);
    
                if (resp.result === true) {
    
                    $$nextConnection$$ = "OK";
                } 
                else {
    
                    log.warn("ivrce_setsduvalue failure");
                }
            }
        } catch (err) {
    
            log.warn("Failure during ivrce_setsduvalue request:" + err);
        }
    } 
    else {
    
        log.warn("failed to find channel id from sip to header");
    }
    
    log.debug('Script Done: nextConnection=' + $$nextConnection$$);
    ]]>
            </data>
          </script>
        </nodes>
      </flow>
    </template>
    
    Sorry, your browser does not support inline SVG. article updatedarticle updated2/21/2024 3:19:17 PM (UTC)2/21/2024 3:19:17 PM (UTC)
    Feedback     Back to top Copyright © Geomant