我有一个简单的机器人,我想设置一个很棒的文字并在其中添加三个按钮
类似这样的东西。
欢迎Johhn到man utd'
第一个按钮
第二个按钮
第三个按钮
这是我尝试过的
$ curl -X POST -H "Content-Type: application/json" -d '{
"greeting": [
{
"locale":"default",
"text":"Hello {{user_first_name}}! Welcome to Man utd"
message: {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [{
"title": "Hi , thanks for messaging videommerce",
"buttons": [{
"type": "postback",
"title": "Select video purpose",
"payload": "purpose"
}, {
"type": "postback",
"title": "How to create video",
"payload": "create"
},{
"type": "web_url",
"url": "https://www.videommerce.com/",
"title": "Talk to us directly (moving to Customerly live chat)"
}],
}]
}
}
}
}
]
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=token"
我需要更改以获得我想要的东西吗?
答案 0 :(得分:0)
问候网钩没有附件属性,如您在此处看到的:documentation。
因此,您的问候语仅适用于参数locale和text:
$ curl -X POST -H "Content-Type: application/json" -d '{
"greeting": [
{
"locale":"default",
"text":"Hello {{user_first_name}}! Welcome to Man utd"
}]}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=token"
如果要向用户显示一些按钮,正确的方法是在发送问候语(即持久菜单)后调用另一个Webhook,如here.所述。此代码将完成工作:
curl -X POST -H "Content-Type: application/json" -d '{
"setting_type" : "call_to_actions",
"thread_state" : "existing_thread",
"call_to_actions":[
{
"type":"postback",
"title":"Help",
"payload":"DEVELOPER_DEFINED_PAYLOAD_FOR_HELP"
},
{
"type":"postback",
"title":"Latest Posts",
"payload":"DEVELOPER_DEFINED_PAYLOAD_FOR_LATEST_POSTS"
},
{
"type":"web_url",
"title":"View Website",
"url":"http://yoursite.com/"
}
]
}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"