Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
titleПример схемы ACR
linenumberstrue
[
	{
		"ringback": {
			"call": {
				"name": "$${ru-ring}",
				"type": "tone"
			},
			"transfer": {
				"name": "$${ru-ring}",
				"type": "tone"
			}
		}
	},
	{
		"setVar": [
			"continue_on_fail=true",
			"hangup_after_bridge=true"
		]
	},
	{
		"answer": "180"
	},
	{
		"httpRequest": {
			"exportCookie": "my_cookie",
			"url": "https://003620-sales-team.bpmonline.com/ServiceModel/AuthService.svc/Login",
			"method": "POST",
			"headers": {
				"Content-Type": "application/json"
			},
			"data": {
				"UserName": "Jon Snow",
				"UserPassword": "Jon Snow"
			}
		}
	},
	{
		"string": {
			"data": "${my_cookie}",
			"fn": "replace",
			"setVar": "BPMCSRF",
			"args": [
				"/.*BPMCSRF=([\\s\\S]*?);(.*)?-._A-Za-z0-9\/]{22});/",
				"$1"
			]
		}
	},
	{
		"httpRequest": {
			"url": "https://003620-sales-team.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": {
				"bpmonline_contact_id": "rows.0.Id",
				"effective_caller_id_name": "rows.0.Name",
				"owner_cell_phone": "rows.0.MobilePhone"
			},
			"data": {
				"QueryType": 0,
				"Columns": {
					"Items": {
						"Id": {
							"OrderDirection": 0,
							"OrderPosition": 0,
							"Caption": null,
							"Expression": {
								"ExpressionType": 0,
								"ColumnPath": "Id"
							}
						},
						"MobilePhone": {
							"OrderDirection": 0,
							"OrderPosition": 0,
							"Caption": null,
							"Expression": {
								"ExpressionType": 0,
								"ColumnPath": "MobilePhone"
							}
						},
						"Name": {
							"OrderDirection": 0,
							"OrderPosition": 0,
							"Caption": null,
							"Expression": {
								"ExpressionType": 0,
								"ColumnPath": "Name"
							}
						}
					}
				},
				"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": "MobilePhone"
							},
							"RightExpression": {
								"ExpressionType": 2,
								"ColumnPath": null,
								"Parameter": {
									"DataValueType": 1,
									"Value": "${caller_id_number}"
								}
							}
						}
					}
				},
				"RootSchemaName": "Contact",
				"OperationType": 0
			}
		}
	},
	{
		"if": {
			"expression": "!${bpmonline_contact_id}",
			"then": [
				{
					"httpRequest": {
						"url": "https://003620-sales-team.bpmonline.com/0/dataservice/json/reply/InsertQuery",
						"method": "POST",
						"headers": {
							"Cookie": "${my_cookie}",
							"BPMCSRF": "${BPMCSRF}",
							"Accept": "application/json;odata=verbose",
							"Content-Type": "application/json"
						},
						"data": {
							"RootSchemaName": "Contact",
							"OperationType": 1,
							"ColumnValues": {
								"Items": {
									"Name": {
										"ExpressionType": 2,
										"Parameter": {
											"DataValueType": 1,
											"Value": "${caller_id_number}"
										}
									},
									"Owner": {
										"ExpressionType": 2,
										"Parameter": {
											"DataValueType": 0,
											"Value": "410006e1-ca4e-4502-a9ec-e54d922d2c00"
										}
									},
									"MobilePhone": {
										"ExpressionType": 2,
										"Parameter": {
											"DataValueType": 1,
											"Value": "${caller_id_number}"
										}
									}
								}
							}
						}
					}
				},
				{
					"httpRequest": {
						"url": "https://003620-sales-team.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": {
							"bpmonline_contact_id": "rows.0.Id"
						},
						"data": {
							"QueryType": 0,
							"Columns": {
								"Items": {
									"Id": {
										"OrderDirection": 0,
										"OrderPosition": 0,
										"Caption": null,
										"Expression": {
											"ExpressionType": 0,
											"ColumnPath": "Id"
										}
									}
								}
							},
							"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": "MobilePhone"
										},
										"RightExpression": {
											"ExpressionType": 2,
											"ColumnPath": null,
											"Parameter": {
												"DataValueType": 1,
												"Value": "${caller_id_number}"
											}
										}
									}
								}
							},
							"RootSchemaName": "Contact",
							"OperationType": 0
						}
					}
				},
				{
					"setVar": [
						"var1=**НОВЫЙ Клиент!**",
						"var2=- [Заполнить данные Контакта](https://003620-sales-team.bpmonline.com/0/Nui/ViewModule.aspx#CardModuleV2/ContactPageV2/edit/${bpmonline_contact_id})"
					]
				}
			],
			"else": [
				{
					"setVar": [
						"var1=- ",
						"var2=- [Открыть карточку контакта](https://003620-sales-team.bpmonline.com/0/Nui/ViewModule.aspx#CardModuleV2/ContactPageV2/edit/${bpmonline_contact_id})"
					]
				}
			]
		}
	},
	{
		"exportVars": [
			"var1",
			"var2"
		]
	},
	{
		"recordSession": {
			"action": "start",
			"type": "mp3",
			"stereo": false,
			"bridged": true,
			"minSec": "3"
		}
	},
	{
		"bridge": {
			"endpoints": [
				{
					"type": "user",
					"name": "100"
				}
			]
		}
	},
	{
		"hangup": ""
	}
]

...