Простой механизм создания Лида с помощью веб-службы DataService с использованием средств преобразования текста в голос и распознавания голоса в webitel.

В справочнике Тип потребности bpm’online я создам новую запись с названием Заказ обратного звонка:

А в справочнике Каналы Лида добавлю наш номер, что бы было легче идентифицировать на какой номер звонил клиент:

Теперь перейдем к настройкам маршрутизации в webitel. Наша схема состоит из нескольких блоков.

Блок 1: Авторизация в bpm’online для получения cookies:

{
    "httpRequest": {
        "exportCookie": "my_cookie",
        "url": "https://001509-sales-commerce.bpmonline.com/ServiceModel/AuthService.svc/Login",
        "method": "POST",
        "headers": {
            "Content-Type": "application/json"
        },
        "data": {
            "UserName": "Администратор",
            "UserPassword": "Администратор"
        }
    }
}

Отправили запрос и сохранили в переменную ответ.

Блок 2: Получение значения идентификаторов новых записей в справочниках bpm’onilne, которые мы создали выше:

{
    "httpRequest": {
        "url": "https://001509-sales-commerce.bpmonline.com/0/dataservice/json/reply/SelectQuery",
        "method": "POST",
        "headers": {
            "Cookie": "${my_cookie}",
            "Accept": "application/json;odata=verbose"
        },
        "exportVariables": {
            "bpmonline_lead_medium_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": "Name"
                        },
                        "RightExpression": {
                            "ExpressionType": 2,
                            "ColumnPath": null,
                            "Parameter": {
                                "DataValueType": 1,
                                "Value": "Звонок:  380947116816 "
                            }
                        }
                    }
                }
            },
            "RootSchemaName": "LeadMedium",
            "OperationType": 0
        }
    }
},
{
    "httpRequest": {
        "url": "https://001509-sales-commerce.bpmonline.com/0/dataservice/json/reply/SelectQuery",
        "method": "POST",
        "headers": {
            "Cookie": "${my_cookie}",
            "Accept": "application/json;odata=verbose"
        },
        "exportVariables": {
            "bpmonline_lead_type_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": "Name"
                        },
                        "RightExpression": {
                            "ExpressionType": 2,
                            "ColumnPath": null,
                            "Parameter": {
                                "DataValueType": 1,
                                "Value": "Заказ обратного звонка"
                            }
                        }
                    }
                }
            },
            "RootSchemaName": "LeadType",
            "OperationType": 0
        }
    }
}



Блок 3: Преобразования текста в речь, с помощью IVONA (DEPRECATED)

{
    "tts": {
        "provider": "ivona",
        "voice": {
            "name": "Tatyana",
            "language": "ru-RU",
            "gender": "Female"
        },
        "text": "Что бы заказать обратный звонок , представьтесь после звукового сигнала! Биииип."
    }
}



Блок 4: Распознание того, что сказал абонент:

{
    "stt": {
        "lang": "ru-RU",
        "maxSec": 8,
        "silenceThresh": 100,
        "silenceHits": 2,
        "setVar": "STT"
    }
}



Блок 5: Создание нового Лида в bpm'online:

{
    "httpRequest": {
        "url": "https://001509-sales-commerce.bpmonline.com/0/dataservice/json/reply/InsertQuery",
        "method": "POST",
        "headers": {
            "Cookie": "${my_cookie}",
            "Accept": "application/json;odata=verbose"
        },
        "data": {
            "RootSchemaName": "Lead",
            "OperationType": 1,
            "ColumnValues": {
                "Items": {
                    "LeadType": {
                        "ExpressionType": 2,
                        "Parameter": {
                            "DataValueType": 0,
                            "Value": "${bpmonline_lead_type_id}"
                        }
                    },
                    "LeadMedium": {
                        "ExpressionType": 2,
                        "Parameter": {
                            "DataValueType": 0,
                            "Value": "${bpmonline_lead_medium_id}"
                        }
                    },
                    "RegisterMethod": {
                        "ExpressionType": 2,
                        "Parameter": {
                            "DataValueType": 0,
                            "Value": "d08186b2-b670-4fdf-9596-7654017f9255"
                        }
                    },
                    "Contact": {
                        "ExpressionType": 2,
                        "Parameter": {
                            "DataValueType": 1,
                            "Value": "${STT}"
                        }
                    },
                    "MobilePhone": {
                        "ExpressionType": 2,
                        "Parameter": {
                            "DataValueType": 1,
                            "Value": "${caller_id_number}"
                        }
                    }
                }
            }
        }
    }
}

Маршрут целиком:

[  
    {
      "answer": "200"
    },
    {
      "httpRequest": {
        "exportCookie": "my_cookie",
        "url": "https://001509-sales-commerce.bpmonline.com/ServiceModel/AuthService.svc/Login",
        "method": "POST",
        "headers": {
          "Content-Type": "application/json"
        },
        "data": {
          "UserName": "Администратор",
          "UserPassword": "Администратор"
        }
      }
    },
    {
      "httpRequest": {
        "url": "https://001509-sales-commerce.bpmonline.com/0/dataservice/json/reply/SelectQuery",
        "method": "POST",
        "headers": {
          "Cookie": "${my_cookie}",
          "Accept": "application/json;odata=verbose"
        },
        "exportVariables": {
          "bpmonline_lead_medium_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": "Name"
                },
                "RightExpression": {
                  "ExpressionType": 2,
                  "ColumnPath": null,
                  "Parameter": {
                    "DataValueType": 1,
                    "Value": "Звонок: +380947116816 "
                  }
                }
              }
            }
          },
          "RootSchemaName": "LeadMedium",
          "OperationType": 0
        }
      }
    },
    {
      "httpRequest": {
        "url": "https://001509-sales-commerce.bpmonline.com/0/dataservice/json/reply/SelectQuery",
        "method": "POST",
        "headers": {
          "Cookie": "${my_cookie}",
          "Accept": "application/json;odata=verbose"
        },
        "exportVariables": {
          "bpmonline_lead_type_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": "Name"
                },
                "RightExpression": {
                  "ExpressionType": 2,
                  "ColumnPath": null,
                  "Parameter": {
                    "DataValueType": 1,
                    "Value": "Заказ обратного звонка"
                  }
                }
              }
            }
          },
          "RootSchemaName": "LeadType",
          "OperationType": 0
        }
      }
    },
    {
      "tts": {
        "provider": "ivona",
        "voice": {
          "name": "Tatyana",
          "language": "ru-RU",
          "gender": "Female"
        },
        "text": "Что бы заказать обратный звонок , представьтесь после звукового сигнала! Биииип."
      }
    },
    {
      "stt": {
        "lang": "ru-RU",
        "maxSec": 8,
        "silenceThresh": 100,
        "silenceHits": 2,
        "setVar": "STT"
      }
    },
    {
      "httpRequest": {
        "url": "https://001509-sales-commerce.bpmonline.com/0/dataservice/json/reply/InsertQuery",
        "method": "POST",
        "headers": {
          "Cookie": "${my_cookie}",
          "Accept": "application/json;odata=verbose"
        },
        "data": {
          "RootSchemaName": "Lead",
          "OperationType": 1,
          "ColumnValues": {
            "Items": {
              "LeadType": {
                "ExpressionType": 2,
                "Parameter": {
                  "DataValueType": 0,
                  "Value": "${bpmonline_lead_type_id}"
                }
              },
              "LeadMedium": {
                "ExpressionType": 2,
                "Parameter": {
                  "DataValueType": 0,
                  "Value": "${bpmonline_lead_medium_id}"
                }
              },
              "RegisterMethod": {
                "ExpressionType": 2,
                "Parameter": {
                  "DataValueType": 0,
                  "Value": "d08186b2-b670-4fdf-9596-7654017f9255"
                }
              },
              "Contact": {
                "ExpressionType": 2,
                "Parameter": {
                  "DataValueType": 1,
                  "Value": "${STT}"
                }
              },
              "MobilePhone": {
                "ExpressionType": 2,
                "Parameter": {
                  "DataValueType": 1,
                  "Value": "${caller_id_number}"
                }
              }
            }
          }
        }
      }
    },
    {
      "tts": {
        "provider": "ivona",
        "voice": {
          "name": "Tatyana",
          "language": "ru-RU",
          "gender": "Female"
        },
        "text": "Спасибо! Ожидайте звонка менеджера."
      }
    },
    {
      "hangup": ""
    }
]



Как результат, имеем новую запись в разделе Лиды:

А вот и наш канал поступления (номер на который клиент позвонил):

Оригинальная запись