Facebook Messenger Chatbot 不发送回复

问题描述 投票:0回答:2
function(resolve, reject) {
        request({
            url: "https://graph.facebook.com/v16.0/me/messages",
            qs: { 'access_token': process.env.PAGE_ACCESS_TOKEN },
            method: "POST",
            json: {
                recipient: { id: recipientId },
                message: message
            }
        }, function (error, response, body) {
            if(error) {
                console.log("Error sending message: " + response.error)
            } else {
                console.log("Message supposed to be sent: " + message)
                console.log(body)
            }
        })
    })
}

这是负责发送消息的功能。 运行时它运行成功。触发

console.log("Message supposed to be sent: " + message)
console.log(body)

然后打印出来

Message supposed to be sent: sample text
{
  error: {
    message: '(#100) Message cannot be empty, must provide valid attachment or text',
    type: 'OAuthException',
    code: 100,
    error_subcode: 2018034,
    fbtrace_id: 'sometraceid'
  }
}

这是我的错还是元的错?

facebook-messenger-bot
2个回答
0
投票
      json: {
                recipient: { id: recipientId },
                message: message
            }

这部分应该是

      json: {
                recipient: { id: recipientId },
                message: { text: "your message"}
            }

0
投票

你能分享一下代码吗?或者你在哪里找到它,因为我想制作自己的聊天机器人,但我不知道从哪里开始。

© www.soinside.com 2019 - 2024. All rights reserved.