Custom IVR Template: CLI Check
Purpose of the Template
Provides the ability to treat callers differently based on the first digits of their calling number. 9 different cases are offered by default (expandable).
Basically you assign parameters (eg m_case1
) to variables containing a prefix (eg +44) and when the calling number's first digits match the variable, the call itself can be diverted to a different node in the menu tree via out1
. Outelse
is an exit point used when none of the variables passed matched the calling number.
Template Data Sheet
Name |
Minimum Engine version |
Minimum Designer version |
CLICheck |
2.1.0 |
7.5.0 |
Parameters
Name |
Description |
m_case1 |
variable with a calling number prefix |
m_case2 |
variable with a calling number prefix |
m_case3 |
variable with a calling number prefix |
... |
|
m_case9 |
variable with a calling number prefix |
Exit Points
Name |
Description |
out1 |
out1 |
out2 |
out2 |
out3 |
out3 |
... |
|
outelse |
outelse |
JSON
{
"name": "CLICheck",
"type": "template",
"description": "<b>CLICheck</b> template:<br/> CLICheck.",
"attributes": [
{
"name": "id",
"type": "integer",
"defaultvalue": "6000"
}
],
"parameters": [
{
"name": "m_case1"
},
{
"name": "m_case2"
},
{
"name": "m_case3"
},
{
"name": "m_case4"
},
{
"name": "m_case5"
},
{
"name": "m_case6"
},
{
"name": "m_case7"
},
{
"name": "m_case8"
},
{
"name": "m_case9"
},
{
"name": "m_caseelse"
}
],
"connections": [
{
"name": "out1"
},
{
"name": "out2"
},
{
"name": "out3"
},
{
"name": "out4"
},
{
"name": "out5"
},
{
"name": "out6"
},
{
"name": "out7"
},
{
"name": "out8"
},
{
"name": "out9"
},
{
"name": "outelse"
}
]
}
XML
<template name="CLICheck" id="#ID#" version="1.0">
<constraints>
<errors AllAttributesRequired="true" />
<warnings MinIncomingConnections="1" />
</constraints>
<parameters>
<parameter id="m_case1">
<![CDATA[#M_CASE1#]]>
</parameter>
<parameter id="m_case2">
<![CDATA[#M_CASE2#]]>
</parameter>
<parameter id="m_case3">
<![CDATA[#M_CASE3#]]>
</parameter>
<parameter id="m_case4">
<![CDATA[#M_CASE4#]]>
</parameter>
<parameter id="m_case5">
<![CDATA[#M_CASE5#]]>
</parameter>
<parameter id="m_case6">
<![CDATA[#M_CASE6#]]>
</parameter>
<parameter id="m_case7">
<![CDATA[#M_CASE7#]]>
</parameter>
<parameter id="m_case8">
<![CDATA[#M_CASE8#]]>
</parameter>
<parameter id="m_case9">
<![CDATA[#M_CASE9#]]>
</parameter>
<parameter id="m_caseelse">
<![CDATA[#M_CASEELSE#]]>
</parameter>
</parameters>
<connections namedoutputs="true">
<connection name="out1" destination="#OUT1#" />
<connection name="out2" destination="#OUT2#" />
<connection name="out3" destination="#OUT3#" />
<connection name="out4" destination="#OUT4#" />
<connection name="out5" destination="#OUT5#" />
<connection name="out6" destination="#OUT6#" />
<connection name="out7" destination="#OUT7#" />
<connection name="out8" destination="#OUT8#" />
<connection name="out9" destination="#OUT9#" />
<connection name="outelse" destination="#OUTELSE#" />
</connections>
<flow>
<nodes>
<script id="30">
<parameters>
<parameter id="m_case1" type="variable" datatype="string" direction="input">?</parameter>
<parameter id="m_case2" type="variable" datatype="string" direction="input">?</parameter>
<parameter id="m_case3" type="variable" datatype="string" direction="input">?</parameter>
<parameter id="m_case4" type="variable" datatype="string" direction="input">?</parameter>
<parameter id="m_case5" type="variable" datatype="string" direction="input">?</parameter>
<parameter id="m_case6" type="variable" datatype="string" direction="input">?</parameter>
<parameter id="m_case7" type="variable" datatype="string" direction="input">?</parameter>
<parameter id="m_case8" type="variable" datatype="string" direction="input">?</parameter>
<parameter id="m_case9" type="variable" datatype="string" direction="input">?</parameter>
<parameter id="m_caseelse" type="variable" datatype="string" direction="input">?</parameter>
</parameters>
<connections namedoutputs="true">
<connection name="OUT1" exitpoint="out1" destination="?"/>
<connection name="OUT2" exitpoint="out2" destination="?"/>
<connection name="OUT3" exitpoint="out3" destination="?"/>
<connection name="OUT4" exitpoint="out4" destination="?"/>
<connection name="OUT5" exitpoint="out5" destination="?"/>
<connection name="OUT6" exitpoint="out6" destination="?"/>
<connection name="OUT7" exitpoint="out7" destination="?"/>
<connection name="OUT8" exitpoint="out8" destination="?"/>
<connection name="OUT9" exitpoint="out9" destination="?"/>
<connection name="OUTELSE" exitpoint="outelse" destination="?"/>
</connections>
<data>
<![CDATA[
function containsPrefix(scaller, sprefixes) {
if ((scaller === null) || (sprefixes=== null)) return false;
if (scaller.length == 0) return false;
if (sprefixes.length == 0) return false;
var prefixes = sprefixes.split(",");
if (typeof(prefixes) === 'string') {
return scaller.startWith(prefixes);
}
for(var i =0;i<prefixes.length;i++) {
if (prefixes[i].length > 0) {
if (scaller.startsWith(prefixes[i])) {
return true;
}
}
}
return false;
}
$$nextConnection$$ = 'OUTELSE';
try {
var hfrom = '' + headers['FROM'];
var caller = null;
var m = hfrom.match(/^.*<sip:(\+?\d+)(\D.*)?@.*$/);
if ((m != null) && (m.length > 1)) {
caller = m[1];
} if (caller == null) {
$$nextConnection$$ = "OUTELSE";
} else {
if (containsPrefix(caller, '' + LOCALS['m_case1'])) $$nextConnection$$ = 'OUT1';
else if (containsPrefix(caller, '' + LOCALS['m_case2'])) $$nextConnection$$ = 'OUT2';
else if (containsPrefix(caller, '' + LOCALS['m_case3'])) $$nextConnection$$ = 'OUT3';
else if (containsPrefix(caller, '' + LOCALS['m_case4'])) $$nextConnection$$ = 'OUT4';
else if (containsPrefix(caller, '' + LOCALS['m_case5'])) $$nextConnection$$ = 'OUT5';
else if (containsPrefix(caller, '' + LOCALS['m_case6'])) $$nextConnection$$ = 'OUT6';
else if (containsPrefix(caller, '' + LOCALS['m_case7'])) $$nextConnection$$ = 'OUT7';
else if (containsPrefix(caller, '' + LOCALS['m_case8'])) $$nextConnection$$ = 'OUT8';
else if (containsPrefix(caller, '' + LOCALS['m_case9'])) $$nextConnection$$ = 'OUT9';
else $$nextConnection$$ = 'OUTELSE';
}
} catch (err) {
$$nextConnection$$ = 'OUTELSE';
log.error('Error in script:' + err);
}
log.debug('Script Done: nextConnection=' + $$nextConnection$$);
]]>
</data>
</script>
</nodes>
</flow>
</template>