FB Messenger Message Template

2019-04-13 07:43发布

问题:

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"
              }              
            ]
          }
        ]
      }
    }
  }