任何方式Facebook机器人按钮模板限制?

时间:2016-06-16 01:28:35

标签: facebook button chat bots messenger

对于Facebook Bots聊天系统中的按钮消息类型,似乎(未记录),最多有3个按钮。这似乎是武断和限制的。有谁知道有没有办法超过3个按钮?

要清楚,我指的是以下消息JSON:

{
  "recipient":{
    "id":"USER_ID"
  },
  "message":{
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"button",
        "text":"What do you want to do next?",
        "buttons":[
          {
            "type":"web_url",
            "url":"https://petersapparel.parseapp.com",
            "title":"Show Website"
          },
          {
            "type":"postback",
            "title":"Start Chatting",
            "payload":"USER_DEFINED_PAYLOAD"
          }
        ]
      }
    }
  }
}

4 个答案:

答案 0 :(得分:20)

没有办法绕过这个限制。 Facebook已明确记录了通用模板here的限制:

  

标题:80个字符

     

副标题:80个字符

     

号召性用语标题:20个字符

     

号召性用语:3个按钮

     

每条消息的气泡(水平滚动):10个元素

一个气泡中最多可以有3个按钮。你可以用另外3个按钮添加另一个气泡。例如:

{
  "recipient": {
    "id": "RECIPIENT_ID"
  },
  "message": {
    "attachment": {
      "type": "template",
      "payload": {
        "template_type": "generic",
        "elements": [
          {
            "title": "Swipe left/right for more options.",
            "buttons": [
              {
                "type": "postback",
                "title": "Button 1",
                "payload": "button1"
              },
              {
                "type": "postback",
                "title": "Button 2",
                "payload": "button2"
              },
              {
                "type": "postback",
                "title": "Button 3",
                "payload": "button3"
              }
            ]
          },
          {
            "title": "Swipe left/right for more options.",
            "buttons": [
              {
                "type": "postback",
                "title": "Button 4",
                "payload": "button4"
              },
              {
                "type": "postback",
                "title": "Button 5",
                "payload": "button5"
              },
              {
                "type": "postback",
                "title": "Button 6",
                "payload": "button6"
              }
            ]
          }
        ]
      }
    }
  }
}

您可以在一个通用模板中添加最多10个气泡。

您可以使用quick replies

答案 1 :(得分:6)

您还可以使用“快速回复”:https://developers.facebook.com/docs/messenger-platform/send-api-reference/quick-replies

快速回复允许您在一行按钮中最多显示11个选项:

facebook quick replies

答案 2 :(得分:4)

您可以使用botframework方法。它使用通用模板发送选项。 options part 1options part 2

"attachment": {
    "type": "template",
    "payload": {
        "template_type": "generic",
        "elements": [{
            "title": "group of options part 1",                    
            "buttons": [ {
                "type": "postback",
                "title": "option 1",
                "payload": "option 1",
            }, ...,
            {
                "type": "postback",
                "title": "option 3",
                "payload": "option 3",
            }],
        }, ..., 
        {
            "title": "group of options 10",
            "buttons": [{
                "type": "postback",
                "title": "option 28",
                "payload": "option 28",
            }, ...,
            {
                "type": "postback",
                "title": "option 30",
                "payload": "option 30",
            }],
        }]
    }
}

答案 3 :(得分:0)

你可以试试这个:

 "text": msg,
        "quick_replies": [
        {

            "content_type": "text",
            "title": "What happens to my healthcare benefits?",
            "payload": "HEALTHCARE_BENEFITS"

        },
        {
            "content_type": "text",
            "title": "What happens to my service credit purchases?",
            "payload": "SERVICE_CREDIT_PURCHASE"

        },
        {
            "content_type": "text",
            "title": "Am I eligible for enhanced contributions?",
            "payload": "ENHANCED_CONTRIBUTIONS"

        },
        {
            "content_type": "text",
            "title": "What is the New Hybrid Plan?",
            "payload": "NEW_HYBRID_PLAN"

        }
    ]

    }
}