我有一个 Dialogflow 聊天机器人。在 Dialogflow 内部测试中,一切正常,但在 facebook 上显示的版本中,我无法获得卡片或建议。即使我用另一个工作聊天机器人的代码替换它们。
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion, Payload} = require('dialogflow-fulfillment');
var answers = [];
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
function welcome(agent) {
agent.add('Hi! Do you want to discover your lockdown personality?');
agent.add(new Card({
title: '1. How has the COVID-19 crisis',
imageUrl: 'https://ejoy-english.com/blog/wp-content/uploads/2018/08/shutterstock_524250877-e1496428580440.jpg',
text: 'impacted the stability of your life?',
})
);
agent.add(new Suggestion("1 more exasperated and hopeless"));
agent.add(new Suggestion("2 less freaked out than other people"));
agent.add(new Suggestion("3 More calm and hopeful"));
agent.add(new Suggestion("4 More scared and panicked"));
agent.add(new Suggestion("5 More surprised and baffled"));
}
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
agent.handleRequest(intentMap);
});
这是我在 Facebook 上得到的信息:
在 Dialogflow 的内部测试器中:
它在 Slack 上运行良好,我设法做了另一个聊天机器人,它也使用丰富的消息而不使用 JSON 有效负载,它在 Messenger 上运行良好。我不知道为什么不能使用这个特定的聊天机器人在 Messenger 中显示丰富的消息。