The task is as follows

When an inbound call is received, get the internal number of the responsible person in CRM Creatio, direct the call to him (10 seconds), if there is no answer, send it to the secretary's number, 100.

Implementation

In the section with public routes add a new scheme for the inbound number:

Screen Shot 2016-06-27 at 14.01.44.png

Example of Inbound Routing:


[
    {
        "ringback": {
            "call": {
                "name": "$${ru-ring}",
                "type": "tone"
            },
            "transfer": {
                "name": "$${ru-ring}",
                "type": "tone"
            }
        }
    },
{
            "httpRequest": {
            "exportCookie": "my_cookie",
            "url": "https://example.bpmonline.com/ServiceModel/AuthService.svc/Login",
            "method": "POST",
            "headers": {
                "Content-Type": "application/json"
            },
            "data": {
                "UserName": "Supervisor",
                "UserPassword": "Supervisor"
            }
        }
    },
    {
        "string": {
            "fn": "reverse",
            "data": "${caller_id_number}",
            "setVar": "reverted_caller_id_number"
        }
    },
    {
        "string": {
            "data": "${my_cookie}",
            "fn": "replace",
            "setVar": "BPMCSRF",
            "args": [
                "/.*BPMCSRF=([^;$]+).*/",
                "$1"
            ]
        }
    },
    {
        "httpRequest": {
            "url": "https://example.bpmonline.com/0/dataservice/json/reply/SelectQuery",
            "method": "POST",
            "headers": {
                "Cookie": "${my_cookie}",
                "BPMCSRF": "${BPMCSRF}",
                "Accept": "application/json;odata=verbose",
                "Content-Type": "application/json"
            },
            "exportVariables": {
                "Contact": "rows.0.Name",
                "owner_caller_id_number": "rows.0.OwnerLogin"
            },
            "data": {
                "QueryType": 0,
                "Columns": {
                    "Items": {
                        "Name": {
                            "OrderDirection": 0,
                            "OrderPosition": 0,
                            "Caption": null,
                            "Expression": {
                                "ExpressionType": 0,
                                "ColumnPath": "Name"
                            }
                        },
                        "OwnerLogin": {
                            "OrderDirection": 0,
                            "OrderPosition": 0,
                            "Caption": null,
                            "Expression": {
                                "ExpressionType": 0,
                                "ColumnPath": "[WSysAccount:Contact:Owner].Login"
                            }
                        }
                    }
                },
                "AllColumns": false,
                "IsDistinct": false,
                "RowCount": 1,
                "Filters": {
                    "FilterType": 6,
                    "ComparisonType": 0,
                    "LogicalOperation": 0,
                    "IsNull": true,
                    "IsEnabled": true,
                    "IsNot": false,
                    "Items": {
                        "FilterByPhone": {
                            "FilterType": 1,
                            "ComparisonType": 9,
                            "LogicalOperation": 0,
                            "IsNull": true,
                            "IsEnabled": true,
                            "IsNot": false,
                            "LeftExpression": {
                                "ExpressionType": 0,
                                "ColumnPath": "[ContactCommunication:Contact].SearchNumber"
                            },
                            "RightExpression": {
                                "ExpressionType": 2,
                                "ColumnPath": null,
                                "Parameter": {
                                    "DataValueType": 1,
                                    "Value": "${reverted_caller_id_number}"
                                }
                            }
                        }
                    }
                },
                "RootSchemaName": "Contact",
                "OperationType": 0
            }
        }
    },
    {
        "setVar": [
            "continue_on_fail=true",
            "hangup_after_bridge=true",
            "ignore_early_media=true"
        ]
    },
    {
        "answer": "183"
    },
    {
        "if": {
            "expression": "${owner_caller_id_number}",
            "then": [
                {
                    "bridge": {
                        "endpoints": [
                            {
                                "name": "${owner_caller_id_number}",
                                "type": "user",
                                "parameters": [
                                    "leg_timeout=10"
                                ]
                            }
                        ]
                    }
                }
            ]
        }
    },
    {
        "bridge": {
            "endpoints": [
                {
                    "name": "100",
                    "type": "user"
                }
            ]
        }
    }
]

Description of variables:

Line numberApplicationDescription
3ringbackRBT -  sets the tone for beeps.
15httpRequestPass authorization in CRM Creatio and receive cookies for further requests.
29string"Expand" the phone number for a request in  CRM Creatio.
36stringGet the value of the token from the cookie into the BPMCSRF variable.
47httpRequest  Execute the request and save the value of the number of the responsible person to the variable  "owner_caller_id_number".
133IFIf the variable is not empty then...
137bridgeCall to the responsible agent in charge for 10 seconds.
153bridgeCall the secretary's number.


You need to change the following values ​​from the example:

urlinstead of "https: //example.bpmonline.com ....." indicate a link to your CRM Creatio;
UserName  - username with administrator rights;
UserPassword
password for this user with administrator rights.


Important!

Please note that if the user password is changed in CRM Creatio, the new password must be specified in the request as well. Otherwise, authorization will not take place and Webitel will not be able to receive data from CRM Creatio.




  • No labels