0

我是 chatfuel 机器人平台的新手。

我正在使用 json api 插件(如文档https://docs.chatfuel.com/api/json-api/json-api

在我的后端,我为插件生成以下 json 响应,这是我的后端 URL: http: //185.206.145.26 :12223/latestnews?locale=en_US&first%20name=John

{
  "messages": [
    {
      "text": "Hi Fety! There are the latest news"
    },
    {
  "attachment": {
    "type": "template",
    "payload": {
      "template_type": "generic",
      "elements": [
        {
          "image_url": "http://scd.rfi.fr/sites/filesrfi/imagecache/rfi_43_medium/sites/images.rfi.fr/files/aef_image/2019-01-11t145823z_1912744290_rc1428cade00_rtrmadp_3_sudan-protests_0.jpg",
          "title": "Soudan: les manifestations se poursuivent, la répression aussi",
          "subtitle": "www.rfi.fr, 2019-01-12 04:03",
          "buttons": [
            {
              "type": "web_url",
              "url": "http://www.rfi.fr/afrique/20190112-soudan-manifestations-poursuivent-repression",
              "title": "VOIR L'ARTICLE"
            }
          ]
        },
        {
          "image_url": "http://scd.rfi.fr/sites/filesrfi/imagecache/rfi_43_medium/sites/images.rfi.fr/files/aef_image/2019-01-11t182406z_855534608_rc1a370ea010_rtrmadp_3_usa-shutdown-lawsuit_0.jpg",
          "title": "[Reportage] «Shutdown»: un quotidien compliqué pour des milliers d'employés",
          "subtitle": "www.rfi.fr, 2019-01-12 04:01",
          "buttons": [
                {
                  "type": "web_url",
                  "url": "http://www.rfi.fr/ameriques/20190112-reportage-shutdown-quotidien-complique-800000-employes",
                  "title": "VOIR L'ARTICLE"
                }
              ]
            }
          ]
        }
      }
    }
  ]
}

问题是当我从块中调用这个 api 时,只有发送的文本对象而不是附件的情况。我确信我的 json 结构没问题,但我不得不错过一些关于 chatfuel 的技巧。

谢谢!

4

1 回答 1

0

我现在坐在沙发上,但我很确定“附件”是信息的组成部分,而不是信息。您已将其作为消息对象本身在消息数组下。

解决方案是将其移动到上面的消息对象中,在“文本”之后。

于 2019-05-14T12:12:27.407 回答