Show / Hide Table of Contents

    Custom IVR Template: CE Transfer

    Transfers the call using Contact Expert.

    Template Data Sheet

    Name Minimum Engine version Minimum Designer version
    CETransfer 2.3.0 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_destination Transfer destination.

    Exit Points

    Name Description
    error Transfer failed
    ok Transfer completed

    JSON

    {
      "name": "CETransfer",
      "type": "template",
      "description": "<b>CETransfer</b> template:<br/> Transfer call using CE.",
      "attributes": [
        {
          "name": "id",
          "type": "integer",
          "defaultvalue": "9400"
        }
      ],
      "parameters": [
        {
          "name": "m_compsrv"
        },
        {
          "name": "m_sduid"
        },
        {
          "name": "m_destination"
        }
      ],
      "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_destination">
          <![CDATA[#M_DESTINATION#]]>
        </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_destination" 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_transfer";
            req["channel"] = chanid;
            req["sduid"] = '' + LOCALS["m_sduid"];
            var sdest = '' + LOCALS["m_destination"];
    
            if (sdest.startsWith("sip:")) {
    
                if (typeof ConversationID !== 'undefined') {
    
                    // no need to pass convid
                    //sdest = "{0};ce-convid={1}".format(sdest,ConversationID.Value);
                }
            }
    
            req["destination"] = sdest;
             
            var resp = js.postData(compsrvurl, timeout, JSON.stringify(req), mimetype);
    
            if (resp == null) {
    
                log.error("Null response for ivrce_transfer");
            } 
            else {
    
                log.debug("ivrce_transfer response:" + resp);
    
                var resp = JSON.parse(resp);
    
                if (resp.result === true) {
    
                    $$nextConnection$$ = "OK";
                } 
                else {
    
                    log.warn("ivrce_transfer failure");
                }
            }
        } 
        catch (err) {
    
            log.warn("Failure during ivrce_transfer 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