微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用键盘将“欢迎消息”发送给Viber bot

如何解决使用键盘将“欢迎消息”发送给Viber bot

Viber API允许以conversation_started事件类型发送一些消息,以允许用户订阅。从documentation about "welcome message",我看到以下代码,该代码成功发送了文本和图像:

{
    "sender": {
        "name": "John Mcclane","avatar": "http://avatar.example.com"
    },"tracking_data": "tracking data","type": "text","text": "Welcome to our bot!","media": "http://www.images.com/img.jpg","thumbnail": "http://www.images.com/thumb.jpg"
}

但是如何在其中添加一些按钮?
我希望用户能够强迫他们订阅并开始与我的机器人进行对话。

我试图在邮件添加以下内容,但没有成功:

"keyboard": {
    "Type": "keyboard","DefaultHeight": true,"Buttons": [{
        "ActionType": "reply","ActionBody": "reply to me","Text": "Key text","TextSize": "regular"
    }]
}

解决方法

经过一些尝试,我发现不能同时使用 media thumbnail keyboard 中的同一“欢迎消息”中。因此,我删除了mediathumbnail键。现在,以下代码有效:

{
    "sender": {
        "name": "John McClane","avatar": "http://avatar.example.com"
    },"tracking_data": "tracking data","type": "text","text": "Welcome to our bot!","keyboard": {
        "Type": "keyboard","DefaultHeight": true,"Buttons": [{
            "ActionType": "reply","ActionBody": "reply to me","Text": "Key text","TextSize": "regular"
        }]
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。