- Created by Olga Zaritska, last modified on Sept 13, 2024
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 4 Current »
Operators
if
The 'if' operator controls conditional branching.
{ "if": { "expression": "${myVar} == '1'", "then": [], "else": [] } }
switch
The "switch" and "case" operators help manage complex conditional operations and branching operations.
{ "switch": { "variable": "${getIvrDigit}", "case": { "1": [], "2": [], "3": [], "default": [] } } }
while
The logic works the same as in programming languages. The first time applications in the [do] block are executed without condition checking. Subsequent times, they are executed only if the condition is true.
{ "while": { "condition": "${myVar} < 10", "maxSteps": "1000", "do": [ { "log": "log is ${myVar}" }, { "js": { "data": "+${myVar} + 1", "setVar": "myVar" } } ] } }
condition - the condition, written considering JavaScript syntax.
maxSteps - the global parameter controls the maximum number of steps within the block (done so that if, for example, a loop is called again from a 'goto' statement later in the schema, the schema does not get stuck in a loop). If not specified, the default value is 1000.
do – an array of applications that will be executed in a loop.
Triggers
disconnected
Executes a set of applications after the main script has finished. Declared once at the beginning of the script.
{ "trigger": { "disconnected": [] } }
commands
Commands currently only affect all `recvMessage` in the schema. If a command is executed, then the `recvMessage` timeout is updated.
{ "trigger": { "commands": { "/queue": [ { "sendText": "queue" } ], "/show map": [ { "sendText": "map" } ], "press button 1": [ { "sendText": "button" } ] }, "disconnected": [ { "dump": true } ] } }, { "sendText": "start" }, { "recvMessage": { "set": "текст", "timeout": 20 } },
Functions
function
Combine a set of applications into a named function. Declared at the beginning of the script.
{ "function": { "name": "myFunction", "actions": [] } }
execute
Execution of a previously declared function by its name.
{ "execute": { "name": "myFunction" } }
Variables
set
Assigning variables to a channel.
{ "set": { "hangup_after_bridge": "true", "ivrLang": "en" } }
export
Exporting variables to the operator's side, as well as to the statistics.
{ "export": [ "reverted_caller_id_number" ] },
unSet
Unsetting a variable.
{ "unSet": [ "reverted_caller_id_number" ] }
Utility applications
calendar
The application allows checking the current time against the working calendar. The value is saved into a variable.
{ "calendar": { "extended": false, "name": "WorkDay", "setVar": "isWorkDay" } }
cache
The application allows working with data in memory or on a Redis server.
[ { "cache": { "action": "set", "set": { "data": { "key": "value" }, "ttl": "10000" }, "type": "memory" } }, { "cache": { "action": "get", "get": { "myVar": "key" }, "type": "redis" } }, { "cache": { "action": "delete", "delete": { "keys": [ "key", "key1" ] }, "type": "redis" } } ]
httpRequest
Performing an HTTP REST request and processing the result (get JSON)
{ "httpRequest": { "url": "https://sales.bpmonline.com/${id}/dataservice/json/reply/SelectQuery", "method": "POST", "timeout": 1000, "insecureSkipVerify": false, "parser": "application/json", "cacheCookie": false, "responseCode": "http_response_code", "headers": { "Content-Type":"application/json", "Cookie": "${my_cookie}" }, "path": { "id": 0 }, "data": { "Name": "Supervisor", "UserID": "Supervisor" }, "exportVariables": { "effective_caller_id_name": "callerIdName", "owner_caller_id_number": "callerIdOwner" } } }
js
Executing arbitrary JavaScript code with the return of the result into a variable.
{ "js": { "data": "var time = LocalDate(); time.setDate(time.getDate() + (+${dpd}*-1)); return time.getMonth() + '-' + time.getDate() + '-' + time.getFullYear()", "setVar": "myVar" } }
math
An application for working with mathematical functions
{ "math": { "data": "${caller_id_array}", "setVar": "new_random_caller_id", "fn": "random" } }
fn
random
: returns a random number from arraymin
andmax
: can be used to find the lowest or highest value in a list of argumentsround
: rounds a number to the nearest integerceil
: rounds a number up to the nearest integerfloor
: rounds a number down to the nearest integer
string
An application for working with strings.
{ "string": { "data": "${caller_id_number}", "fn": "replace", "setVar": "reverted_caller_id_number", "args": [ "/^0/", "+84" ], } }
fn
length
: returns the length of a stringindexOf
andlastIndexOf
: returns the index of (the position of) the first or last occurrence of a specified text in a stringsearch
: searches a string for a specified value and returns the position of the matchslice
: extracts a part of a string and returns the extracted part in a new stringsubstring
: is similar to slice. The difference is thatsubstring
cannot accept negative indexes.substr
: is similar to slice. The difference is that the second parameter specifies the length of the extracted part.replace
: replaces a specified value with another value in a stringtoUpperCase
ortoLowerCase
: A string is converted to upper case or to lower casecharAt
: returns the character at a specified index (position) in a stringcharCodeAt
: returns the unicode of the character at a specified index in a stringsplit
: A string can be converted to an array with thesplit
functionreverse
: Reverse the provided stringbase64
: base64 encoder / decoderMD5
: Computes a digest from a string usingMD5
algorithmSHA-256
: Computes a digest from a string usingSHA-256
algorithmSHA-512
: Computes a digest from a string usingSHA-512
algorithm
markIVR
Allows saving an array of values into a variable, which will be accessible in the history.
{ "markIVR": { "name": "Log", "value": "Входящий звонок" } }
topicExtraction
topicExtraction For determining the topic of the received message: a chat message, speech-to-text on IVR { "topicExtraction": { "connection": "http://10.10.10.222:3333/extract_topics/", "limit": 2, "messages": [ { "message": "Are you interested in buying a car?", "sender": "operator" }, { "message": "I'm fed up with you, I already told you so", "sender": "user" } ], "possibleTopics": [ "interested", "not interested", "unable to talk" ], "definedTopic": "topicResponse", "score": "confidenceResponse" } }
Where:
- limit – optional, default is 4, these are the most recent messages from the chat or recognition during the call.
- definedTopic – which variable to store the response (topic).
- score – which variable to store the confidence score.
- messages – used for all types except chat/call.
userInfo
The application allows retrieving a value from a user object based on the phone number.
{ "userInfo": { "set": { "usrId": "id", "email": "email", "mob": "variables.fwd_mob", "out": "variables.out_cid" }, "user": { "extension": "${ext}" } } }
setGrantee
Grant channel permissions to the user identified by the specified ID.
{ "setGrantee": { "id": 10 } }
schema
Execute an external schema by its identifier.
{ "schema": { "id": 1 } }
softSleep
Pause script execution for the specified number of milliseconds.{ "softSleep": 1000 }
sql
The application is available exclusively for dedicated or proprietary Webitel servers. It allows executing a query in the database and returning the result into a variable.
[ { "sql": { "dns": "admin:123Webitel4@tcp(database-1.cluster-cnvuzqnsxvyv.eu-central-1.rds.amazonaws.com:3306)/mysql", "driver": "mysql", "params": [ "db" ], "query": "select 1 as tst_number, true as tst_bool, table_name, last_update from mysql.innodb_index_stats where table_name = ? order by rand() limit 1" } }, { "sql": { "dns": "user=webitel password=webitel host=10.9.8.111 dbname=webitel sslmode=disable", "driver": "postgres", "params": [ 12 ], "query": "select user_id from call_center.cc_agent where id = $1", "timeout": 5000 } } ]
list
Checking for the presence of a subscriber in the list and performing actions.
{ "list": { "name": "StopList_Chat_bot", "destination": "${user}", "actions": [ { "sendText": "BAN: ${from} ⛔️", "break": true } ] } }
listAdd
Add a subscriber to the list.
{ "listAdd": { "destination": "${caller_id_number}", "description": "${caller_id_name}", "expireAt": "${expired_at}", "list": { "id": 16 } } }
log
Output additional information to the log file of the applications.
{ "log": " >> ${Hold} <<<" }
goto
Jump to a named label.
{ "goto": "tagName" }
monoPay
Jump to a named label.
{ "monoPay":{ "invoice":{ "action":"create", "body":{ "amount":"1", "paymentType":"debit", "setVar":"monoInvoice", "validity":"3600" } }, "token":"uLRpgdn9yE5JP11NuXVqdvWpKk6TbSiQnquzS2BxtiCw" }
Application parameters
The data of applications can be invoked both independently and as a parameter of another application.
tag
Set a named label in the script.{ "tag": "tagName" }
async
Executing an application without blocking.
{ "async": true }
break
Interrupts script execution.
{ "break": true }
limit
Allows interrupting the loop after passing the specified amount indicated in the 'max' attribute. Exiting is done to the named label specified in the 'failover' attribute.
{ "limit": { "max": 5, "failover": "anotherTag" } }
- No labels
0 Comments