Webhook

概述

webhook允许您将匹配的意图中的信息发送到Web服务并响应结果给一个AI

要求

要与一个AI集成的web服务需要满足以下要求。

验证

  • HTTP头附加认证信息

如果集成服务不需要任何身份验证,请将身份验证字段留空

请求服务的格式

当启用Webhook的意图被触发时,一个AI会以POST请求的形式向您设置的web服务URL发送数据,请求示例及请求格式如下。

CURL请求示例:

curl -k \
-u your_auth_user:your_auth_pass \
-H "Content-Type: application/json; charset=utf-8" \
--data '{
 "lang": "zh-cn",
 "time_zone": "Asia/Shanghai",
 "status": {
     "error_msg": "success",
     "code": 200
 },
 "timestamp": "2017-02-27 21:58:46",
 "result": {
     "query": "找个女朋友",
     "session_id": "52b63b18f3d941bd6c6404bd8f32aa83",
     "agent_id" : "CAF6BEA1-AEA1-6427-24D8-9ECAA4A4BC49",
     "intent_id" : "93F42BCF-5A7C-4F0E-E3AE-EE9A27F0296D",
     "intent_name": "找女朋友",
     "emotion": {
         "positive": 0.0064815573227318,
         "neutral" : 0.98559873739357,
         "negative": 0.007919705283701
     },
     "segmented_query": [
         "找个",
         "女朋友"
     ],
     "action": {
         "name": "find_girlfriend",
         "complete": true,
         "parameters": []
     },
     "webhook": {
         "webhook_used": true,
         "request_url": "http://you-service.com/webhook"
     },
     "answer": "到世纪佳缘:http://www.jiayuan.com"
     }
}' "http://you-service.com/webhook"

向web服务请求示例

 POST https://you-service.com/webhook
 Headers: Content-type : application/json;charset=utf-8
 Authorization: Basic dGVzdDpwYXNz 
 Php-Auth-Pw: auth_pass 
 Php-Auth-User: auth_name POST body:

{
 "lang": "zh-cn",
 "time_zone": "Asia/Shanghai",
 "status": {
    "error_msg": "success",
    "code": 200 
 },
 "timestamp": "2017-02-27 21:58:46",
 "result": {
        "query": "找个女朋友",
        "session_id": "52b63b18f3d941bd6c6404bd8f32aa83",
        "agent_id" : "CAF6BEA1-AEA1-6427-24D8-9ECAA4A4BC49",
        "intent_id" : "93F42BCF-5A7C-4F0E-E3AE-EE9A27F0296D",
        "intent_name": "找女朋友",
        "emotion": {
            "positive": 0.0064815573227318,
            "neutral" : 0.98559873739357,
            "negative": 0.007919705283701
        },
        "segmented_query": [
            "找个",
            "女朋友"
        ],
        "action": {
            "name": "find_girlfriend",
            "complete": true,
            "parameters": []
        },
        "webhook": {
            "webhook_used": true,
            "request_url": "https://you-service.com/webhook"
        },
        "answer": "到世纪佳缘:http://www.jiayuan.com"     
        }

}

web服务需要响应的数据格式

{
 "status":{
    "error_msg":"success", 
    "code":200
 },
 "answer":"找一个AI~"
}

限制

  • 服务响应超时 - 5秒

Webhook设置

  • 应用配置页面Webhook开启

  • 场景页面Webhook开启

results matching ""

    No results matching ""