4
votes

I am creating a FB messenger chatbot. What is the JSON format through which while sending image URL link, it will generate a preview.

On the above screenshot, you can see that if I manually send a URL, FB messenger will generate the preview. Similarly if the chatbot sends an URL the messenger has to generate the preview. So my query is what is the JSON formate which will even generate the preview if I send an URL?

On the above screenshot, you can see that if I manually send an URL, FB messenger will generate the preview. Similarly if the chatbot sends an URL the messenger has to generate the preview. So my query is what is the JSON formate which will even generate the preview if I send an URL?

Note: I dont want to send image as an attachement, as there are size limitations

1
What do you exactly need? - user7111497
Did you find a way to do this? - Uri Abramson
@UriAbramson Not yet. - Sandesh B Suvarna
@SandeshBSuvarna did you find its solution? - rajat12a
No luck. Have pinged FB dev support too. @Root - Sandesh B Suvarna

1 Answers

0
votes

You would have most control using the generic template (API Docs)

This is a function that sends two news items with preview images and action buttons:

function sendNewsMessage(recipientId) {
  var messageData = {
   recipient: {
      id: recipientId
    },
    message: {
      attachment: {
        type: "template",
        payload: {
          template_type: "generic",
          elements: [{
            title: "Serie: Fischer im Recht",
            subtitle: "Thomas Fischer ist Bundesrichter in Karlsruhe und schreibt für ZEIT und ZEIT ONLINE über Rechtsfragen.",
            item_url: "http://www.zeit.de/serie/fischer-im-recht",               
            image_url: "http://img.zeit.de/autoren/F/Thomas_Fischer/thomas-fischer/wide__300x200__desktop",
            buttons: [{
              type: "web_url",
              url: "http://www.zeit.de/serie/fischer-im-recht",
              title: "Zur Serie"
            }, {
              type: "postback",
              title: "Abonnieren",
              payload: "subscribe-fischer",
            }],
          }, {
            title: "Redaktionsempfehlungen",
            subtitle: "Besonders wichtige Nachrichten und Texte von ZEIT ONLINE",
            item_url: "http://www.zeit.de/administratives/wichtige-nachrichten",               
            image_url: "http://img.zeit.de/angebote/bilder-angebotsbox/2016/bild-angebotsbox-48.jpg/imagegroup/wide",
            buttons: [{
              type: "web_url",
              url: "http://www.zeit.de/administratives/wichtige-nachrichten",
              title: "Zur Übersicht"
            }, {
              type: "postback",
              title: "Abonnieren",
              payload: "subscribe-news",
            }]
          }]
        }
      }
    }
  };
  callSendAPI(messageData);
}

This way you are sending links to images instead of sending attachements.