salesmartly_webhook
    salesmartly_webhook
    • Webhook接受消息接口文档
    • Webhook接受事件接口文档
    • 主动发送信息接口文档

    Webhook接受消息接口文档

    一、接收消息#

    1.概述#

    需根据本产品的规范,对添加的 webhook 地址,实现一个 post 请求接口。
    Post 请求用于:推送信息到配置的 webhook 地址。

    2. 配置参数#

    url(String):webhook 的请求地址。
    secret(String):用于使 webhook 验证本产品有效性。

    3. 调用 webhook#

    当接收到新信息时,调用 webhook 进行消息推送。
    Post 请求,url 为用户配置的 http(s)://host。

    3.1 请求地址及参数#


    请求地址:http(s)://host?timestamp=TIMESTAMP&signature=SIGNATURE 地址中携带的参数含义与上述一致,webhook 端可根据 signature 判断请求是否来自于SaleSmartly官方。signature 加密规则是以参数名称按字典序排序后,衔接到 secret 后进行MD5加密的值。(如md5(secret&data=123&event=message) )
    Header
    content-type: “application/json”
    Body
    参数名参数类型参数含义
    eventString推送 webhook 的事件名。”message”表示新消息推送。
    dataObject新消息的数据体

    3.2 data的数据格式#


    当 msgType 为 text 时
    参数名参数类型参数含义
    msg_type *String“text”:文本。
    chat_user_id *String用户id
    sequence_id *Int消息 id
    send_time *String消息发送时间
    msg *String消息内容
    quote_chatString引用回复内容
    chat_session_id *String会话id
    channel *Int社媒渠道 1-Messenger 2-plugin 5-instagram 6-line 7-WhatsApp Api 12-WhatsApp APP 15-Telegram App 16-Tiktok App
    channel_uid *String社媒渠道id
    sender_type *String发送方 1-用户 2-项目成员
    sender *String发送人 (用户id或项目成员id)
    sys_user_id *Int当前接待客服id 小于等于0为未分配或机器人
    当 msgType 为 button 时
    参数名参数类型参数含义
    msg_type *String“button”:点击按钮。
    chat_user_id *String用户id
    sequence_id *Int消息 id
    send_time *String消息发送时间
    msg *String消息内容
    chat_session_id *String会话id
    payload *Object按钮信息
    channel *Int社媒渠道 1-Messenger 6-line 7-WhatsApp Api
    channel_uid *String社媒渠道id
    sender_type *String发送方 1-用户 2-项目成员
    sender *String发送人 (用户id或项目成员id)
    sys_user_id *Int当前接待客服id 小于等于0为未分配或机器人
    当 msgType 为 image 时
    参数名参数类型参数含义
    msg_type *String“image”:图片。
    chat_user_id *String用户id
    sequence_id *Int消息 id
    send_time *String消息发送时间
    msg *String消息内容
    chat_session_id *String会话id
    channel *Int社媒渠道 1-Messenger 2-plugin 5-instagram 6-line 7-WhatsApp Api 12-WhatsApp APP 15-Telegram App 16-Tiktok App
    channel_uid *String社媒渠道id
    sender_type *String发送方 1-用户 2-项目成员
    sender *String发送人 (用户id或项目成员id)
    sys_user_id *Int当前接待客服id 小于等于0为未分配或机器人
    当 msgType 为 file 时
    参数名参数类型参数含义
    msg_type *String“file”:文件。
    chat_user_id *String用户id
    sequence_id *Int消息 id
    send_time *String消息发送时间
    msg *String消息内容
    chat_session_id *String会话id
    channel *Int社媒渠道 1-Messenger 2-plugin 5-instagram 7-WhatsApp Api 12-WhatsApp APP 15-Telegram App
    channel_uid *String社媒渠道id
    sender_type *String发送方 1-用户 2-项目成员
    sender *String发送人 (用户id或项目成员id)
    sys_user_id *Int当前接待客服id 小于等于0为未分配或机器人
    当 msgType 为 system_message 时
    参数名参数类型参数含义
    msg_type *String“system_message”:系统消息。
    chat_user_id *String用户id
    sequence_id *Int消息 id
    send_time *String消息发送时间
    msg *String消息内容
    chat_session_id *String会话id
    channel *Int社媒渠道 12-WhatsApp App
    channel_uid *String社媒渠道id
    sender_type *String发送方 1-用户 2-项目成员
    sender *String发送人 (用户id或项目成员id)
    sys_user_id *Int当前接待客服id 小于等于0为未分配或机器人
    当 msgType 为 email 时
    参数名参数类型参数含义
    msg_type *String“email”:邮件。
    chat_user_id *String用户id
    sequence_id *Int消息 id
    send_time *String消息发送时间
    msg *String邮件相关内容
    chat_session_id *String会话id
    channel *Int社媒渠道 3-Email
    channel_uid *String社媒渠道id
    sender_type *String发送方 1-用户 2-项目成员
    sender *String发送人 (用户id或项目成员id)
    sys_user_id *Int当前接待客服id 小于等于0为未分配或机器人

    3.3 输入示例#


    示例1#
    {
        "event": "message",
        "data": {
            "chat_user_id": "65094291e106072b7e40ff21",
            "sequence_id": "1695787977126000",
            "msg_type": "text",
            "msg": "222222",
            "send_time": "1695787977082",
            "quote_chat": {
                "chat_user_id": "65094291e106072b7e40ff21",
                "sequence_id": "1695799154673000",
                "msg_type": "button",
                "msg": "\u6930\u5b50\u997c\u5e72ok\u561b",
                "send_time": 1695799154645,
                "chat_session_id": 130925
            },
            "chat_session_id": 130925,
            "channel":7,
            "channel_uid": "123@c.us",
            "sender_type": 1,
            "sys_user_id": 0
        },
    }
    示例2#
    {
        "event": "message",
        "data": {
            "chat_user_id": "65094291e106072b7e40ff21",
            "sequence_id": "1695799154673000",
            "msg_type": "button",
            "msg": "\u6930\u5b50\u997c\u5e72ok\u561b",
            "send_time": 1695799154645,
            "payload": {
                "type": "button_reply",
                "button_reply": {
                    "id": "ACT:24545",
                    "title": "\u6930\u5b50\u997c\u5e72ok\u561b"
                }
            },
            "chat_session_id": 130925,
            "channel":7,
            "channel_uid": "123@c.us",
            "sender_type": 1,
            "sys_user_id": 0
        }
    }
    示例3#
    {
        "event": "message",
        "data": {
            "chat_user_id": "65094291e106072b7e40ff21",
            "sequence_id": "1695799154673000",
            "msg_type": "image",
            "msg": "https:\/\/mix-ads.oss-ap-southeast-1.aliyuncs.com\/xxxxx\/xxxxx\/xxxxxx\/xxx.jpeg",
            "send_time": 1695799154645,
            "chat_session_id": 130925,
            "channel":7,
            "channel_uid": "123@c.us",
            "sender_type": 1,
            "sys_user_id": 0
        }
    }
    示例4#
    {
        "event": "message",
        "data": {
            "chat_user_id": "65094291e106072b7e40ff21",
            "sequence_id": "1695799154673000",
            "msg_type": "file",
            "msg": "https:\/\/mix-ads.oss-ap-southeast-1.aliyuncs.com\/xxxxx\/xxxxx\/xxxxxx\/xxx.word",
            "send_time": 1695799154645,
            "chat_session_id": 130925,
            "channel":7,
            "channel_uid": "123@c.us",
            "sender_type": 1,
            "sys_user_id": 0
        }
    }
    示例5#
    {
        "event": "message",
        "data": {
            "chat_user_id": "65094291e106072b7e40ff21",
            "sequence_id": "1695799154673000",
            "msg_type": "system_message",
            "msg": {
                "type":"join_group/leave_group", //事件名称
                "name":"test", // 用户WhatsApp昵称
                "origin_phone": "123321124", //用户手机号码带国家区号
                "country_code": "+1",//国家区号
                "phone": "23321124",//用户号码不带国家区号
                "group_name":"test", // 群组名称
                "group_uid": "123321124@c.us", //群组ID
                "event_id": "notification_17349", //事件ID
                "timestamps": "1720000000", //进/退群时间
            },
            "send_time": 1695799154645,
            "chat_session_id": 130925,
            "channel":12,
            "channel_uid": "123@c.us",
            "sender_type": 1,
            "sys_user_id": 0
        }
    }
    示例6#
    {
        "event": "message",
        "data": {
            "chat_user_id": "65094291e106072b7e40ff21",
            "sequence_id": "1695799154673000",
            "msg_type": "email",
            "msg": {
                "title":"title",
                "msg":"<p>hello<\/p>",
                "attachments":"[]",
            },
            "send_time": 1695799154645,
            "chat_session_id": 130925,
            "channel":12,
            "channel_uid": "123@c.us",
            "sender_type": 1,
            "sys_user_id": 0
        }
    }

    4. 返回 (Email暂不支持返回消息)#

    所有渠道 异常返回格式
    {
        "code":-1,
        "msg":"错误原因",
        "data":{
            "chat_user_id":"65094291e106072b7e40ff21",
            "sequence_id":"1695799154673000",
            "send_time":"1695799154645",
            "channel":7,
            "channel_uid": "123@c.us"
        },
    }
    所有渠道 text 信息格式
    {
        "code":0,
        "msg":"Success",
        "data":{
            "msg_type":1,
            "msg":"\u6930\u5b50\u997c\u5e72\u561b",
            "chat_user_id":"65094291e106072b7e40ff21",
            "chat_session_id":"130925",
            "send_time":"1695799154645",
            "channel":7,
            "channel_uid": "123@c.us"
        }
    }
    所有渠道 image 信息格式
    {
        "code":0,
        "msg":"Success",
        "data":{
            "msg_type":2,
            "msg":"https://123.jpg",
            "chat_user_id":"65094291e106072b7e40ff21",
            "chat_session_id":"130925",
            "send_time":"1695799154645",
            "channel":7,
            "channel_uid": "123@c.us"
        }
    }
    WhatsApp Api 、 Messenger 和 Line 商品信息选择按钮格式
    {
        "code":0,
        "msg":"Success",
        "data":{
            "msg_type":3,
            "msg":{
                "template1":{
                    "image":"https://ss.com",
                    "title":"商品1",
                    "buttons": {
                        "button1":{
                            "id":"ACT:1",
                            "text" : "choose"
                        }
                    }
                },
                "template2":{
                    "image":"https://ss.com",
                    "title":"商品2",
                    "buttons": {
                        "button1":{
                            "id":"ACT:2",
                            "text" : "choose"
                        }
                    }
                },
                // 最多支持五个template
            },
            "chat_user_id":"65094291e106072b7e40ff21",
            "chat_session_id":"130925",
            "send_time":"1695799154645",
            "channel":7,
            "channel_uid": "123@c.us"
        }
    }
    WhatsApp Api 、 Messenger 和 Line 商品信息推送格式
    {
        "code":0,
        "msg":"Success",
        "data":{
            "msg_type":3,
            "msg":{
                "template":{
                    "image":"https://ss.com",
                    "text":"您选择商品是手套,链接:https://ss.com"
                }
            },
            "chat_user_id":"65094291e106072b7e40ff21",
            "chat_session_id":"130925",
            "send_time":"1695799154645",
            "channel":7,
            "channel_uid": "123@c.us"
        }
    }
    Messenger 和 Line 商品模板轮播推送格式
    {
        "code":0,
        "msg":"Success",
        "data":{
            "msg_type":27,
            "msg":{
                "template":{
                    "generic":[
                      {
                        "title":"Welcome!",
                        "image_url":"https://petersfancybrownhats.com/company_image.png",
                        "subtitle":"We have the right hat for everyone.",
                        "buttons":[
                          {
                              "id":"ACT:1",
                              "text":"Start Chatting"
                          } // 最多支持三个button              
                        ]      
                      } // 最多不超过十个generic
                    ]
                }
            },
            "chat_user_id":"65094291e106072b7e40ff21",
            "chat_session_id":"130925",
            "send_time":"1695799154645",
            "channel":2,
            "channel_uid": "123@c.us"
        }
    }
    content-type:”application/json”
    下一页
    Webhook接受事件接口文档
    Built with