【问题标题】:Facebook Chatbot: Animated GIFs in Generic TemplatesFacebook 聊天机器人:通用模板中的 GIF 动画
【发布时间】:2016-12-15 09:25:00
【问题描述】:

通过 Facebook 聊天机器人的通用模板,可以使用动画 GIF 图像。这非常适用于桌面版本。使用 iOS 或 Android 上的 Messenger 应用程序不会播放动画,而是仅显示第一帧。

我可以做些什么来让它在Messenger应用中也能正常工作吗?

以下是有关 Facebook 聊天机器人通用模板的文档:https://developers.facebook.com/docs/messenger-platform/send-api-reference/generic-template

【问题讨论】:

    标签: android ios facebook messenger chatbot


    【解决方案1】:

    我也试过了,但答案就是你所知道的。动画 Gif 可用作单张图片,但不适用于任何模板。我已经阅读了 FB 的所有参考资料并查看了他们发布的所有新闻。但是他们没有提到它,下面是我亲手做的。

    浏览器上的单张图片
    o 应用上的单张图片
    o 浏览器上的模板图片
    x 应用上模板的图片

    o -> 动画
    x -> 停止,只显示第一帧

    【讨论】:

      【解决方案2】:

      当我在通用模板中发布有效的 GIF URL 时,我遇到了同样的问题。您可以看到我发布的一个问题以及我在搜索几个小时后添加的答案。

      很遗憾,目前还不能通过通用模板打印动画 GIF 图像。

      您可以做的解决方案是创建两个有效负载而不是模板。第一个有效负载将发布一个 GIF 图片,第二个是您的按钮,

      代码

      def thanks(req):
          your_welcome_gif=[ "https://media3.giphy.com/media/KCw6QUxe9zBO6QNrFe/giphy.gif", 
                             "https://media1.giphy.com/media/H21d4avBXs8B9X0NLj/giphy.gif", 
                             "https://media1.tenor.com/images/15bafc0b414757acab81650a6ff21963/tenor.gif?itemid=11238673"]
      
          greeding = req.get('queryResult').get('parameters').get('greeding')
      
          if greeding == 'Thank you' or greeding == 'thank you' or greeding == 'Thanks' or greeding == 'thanks' or greeding == 'Nice' or greeding == 'nice':
      
              return {"fulfillmentMessages": [
              {
                  'payload': {
                      "facebook": {
                          "attachment": {
                              "type": "image",
                              "payload":{
                                  "url":random.choice(your_welcome_gif)
                              }
                          }
                      }
                  }
              },    
              {
                  'payload': {
                      "facebook": {
                          "attachment": {
                              "type": "template",
                              "payload": {
                                  "template_type": "button",
                                  "text": "You're welcome :) \nWould you like to choose another movie?",
                                  "buttons": [
                                  {
                                      "type": "postback",
                                      "title":"Yes",
                                      "payload":"Yes"
                                  },
                                  {
                                      "type": "postback",
                                      "title":"No",
                                      "payload":"No"
                                  }
                              ]
                          }
                      }
                  }
              }
          }
      ]}
      

      这是我的question,已上传代码。

      【讨论】:

        【解决方案3】:

        是的,您还发送了一条 gif 消息,但在 url 部分您必须提供该 gif 的有效 url...您可以通过先上传到 git 然后在您必须输入的最后一个 url 来做到这一点。 ...=> ?raw=true 因为在 git 中它以原始格式存储...

        You may see all the details here on my link this chatbot is handling almost every feature in the described in the documents

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2019-01-13
          • 1970-01-01
          • 1970-01-01
          • 2018-09-12
          • 2016-08-14
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多