发送liveChat请求

发送liveChat请求,开启或关闭liveChat

发送请求,开启或关闭liveChat

用户可以在whatsapp上进行智能对话或进行人工对话。当需要人工对话时,Botchat发起开启livechat(状态)请求;若太久未有人工接通,则botchat可发送关闭liveChat(状态)请求;而如果等待到真正接起人工时,livechat向botchat发送start_licechat信号,通知其已接通人工,不用再理会用户的操作;当人工对话结束时livechat向botchat发起关闭liveChat(状态)请求,继续进行智能对话。

发送请求

您可以用任意一个已经启用的API Key(怎样申请APIKey) 向Moli发起关闭liveChat请求、向Bot发起开启livechat请求。这个请求的说明如下:

请求样例

{
    "id" : "<unique request identifier>",
    "user_id" : "<phone number of the user>",
    "source" : "<botchat / livechat>",
    "signal" : "<start_livechat / stop_livechat>",
    "meta" : {
        "selected_email" : "<email of the user>"
    }
}

请求返回值

  • 成功返回值样例

{
    "result": true,
    "data": {}
}
  • 失败返回值样例

{
    "error": {
        "code": 10011,
        "error_subcode": 0,
        "type": "",
        "message": "Request already processed",
        "request_id": 35122312158
    }
}

错误码列表

接口会给subscriber发送信息

不同subscriber发送信息样式不同。

请求样例

{
    "id":"<unique message identifier>",
    "country":"in",
    "email":"<the email>",
    "ts":"<the timestamp>",
    "meta":{
        "conversations":[
            {
                "id":"<unique message identifier>",
                "from":"<phone number of the sender user>",
                "to": "<phone number of the recipient user>",
                "timestamp":"<the timestamp of sending message>",
                "type":"text",
                "text":{
                    "body":"hi"
                }
            },
            {
                "id":"<unique message identifier>",
                "from":"<phone number of the sender user>",
                "to": "<phone number of the recipient user>",
                "timestamp":"<the timestamp of sending message>",
                "type":"image",
                "image":{
                    "url": "<your-media-url>",
                    "caption": "<your-image-caption>",
                    "extension": "<see the list of available extensions>"
                }
            }
        ]
     }
}

Last updated