【问题标题】:Facebook messenger chatbot url previewFacebook Messenger 聊天机器人网址预览
【发布时间】:2016-12-17 15:59:44
【问题描述】:

我正在创建一个 FB Messenger 聊天机器人。发送图片URL链接时会生成预览的JSON格式是什么。

在上面的截图中,你可以看到如果我手动发送一个 URL,FB messenger 会生成预览。同样,如果聊天机器人发送一个 URL,则信使必须生成预览。所以我的查询是什么是 JSON 格式,如果我发送一个 URL,它甚至会生成预览?

注意:我不想将图片作为附件发送,因为有大小限制

【问题讨论】:

  • 你到底需要什么?
  • 你找到方法了吗?
  • @UriAbramson 还没有。
  • @SandeshBSuvarna 你找到解决方案了吗?
  • 不走运。也有 ping FB 开发支持。 @Root

标签: facebook-messenger facebook-messenger-bot


【解决方案1】:

您可以使用generic 模板 (API Docs) 进行大部分控制

这是一个发送两个带有预览图像和操作按钮的新闻项目的函数:

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);
}

这样您发送的是图片链接而不是附件。

【讨论】:

    猜你喜欢
    • 2016-08-14
    • 2020-03-28
    • 1970-01-01
    • 2019-10-29
    • 2019-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多