FB Messenger Message Template

自作多情 提交于 2019-12-06 11:50:14

问题


How can I achieve this template in fb messenger platform?

It seems that the color of the shirt and the price are both subtitles of the message but there can only be 1 subtitle in a message. So how can achieve where there are two subtitles?

This is my current message tempalate

"message":{
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"generic",
        "elements":[
          {
            "title":"Classic T-Shirt",
            "image_url":"http://petersapparel.parseapp.com/img/item100-thumb.png",
            "subtitle":"Medium Grey %0D%0A s",
            "buttons":[
              {
                "type":"web_url",
                "url":"https://petersapparel.parseapp.com/view_item?item_id=100",
                "title":"View details"
              },
              {
                "type":"postback",
                "title":"Buy Now!",
                "payload":"USER_DEFINED_PAYLOAD"
              }              
            ]
          }
        ]
      }
    }
  }

回答1:


You can only add new lines to the message itself, not to titles or buttons or quick replies for ex

    messageData = { 
                    recipient: {id: recipientId},
                    message: {
                     text: "Your First Line \n your second line",
                     metadata:"DEVELOPER_DEFINED_METADATA"
                   }};



回答2:


just add new element.

"message":{
   "attachment":{
      "type":"template",
      "payload":{
        "template_type":"generic",
        "elements":[
          {
            "title":"Classic T-Shirt",
            "image_url":"<link>",
            "subtitle":"Medium Grey %0D%0A s",
            "buttons":[
              {
                "type":"web_url",
                "url":"<link>",
                "title":"View details"
              },
              {
                "type":"postback",
                "title":"Buy Now!",
                "payload":"USER_DEFINED_PAYLOAD"
              }             
            ]
          },
          {
            "title":"Classic T-Shirt",
            "image_url":"<link>",
            "subtitle":"Medium Grey %0D%0A s",
            "buttons":[
              {
                "type":"web_url",
                "url":"<link>",
                "title":"View details"
              },
              {
                "type":"postback",
                "title":"Buy Now!",
                "payload":"USER_DEFINED_PAYLOAD"
              }              
            ]
          }
        ]
      }
    }
  }


来源:https://stackoverflow.com/questions/38429355/fb-messenger-message-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!