I have a Dialogflow chatbot. In the Dialogflow internal tester everything works fine, but in the version displayed on facebook I cannot get the cards or suggestions. Even when I replace them with code from another working chatbot.
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);
});
Here's what I get on Facebook:
And in the Dialogflow's inernal tester:
It's working well on Slack and I managed to do another chatbot which use rich messages as well without using JSON payload and it worked well on messenger. I don't know why can't rich messages be displayed in Messenger with this specific chatbot.
The DialogFlow built-in tester is a good way to validate the conversation flow and test the intent recognition, however about the rendering of the response (from quick replies to attachments) you need to consider that Facebook has a different render engine (same for other channels) so certain types do not play well and they are not definitely standardise.
The solution in this case I believe to provide a custom Facebook payload which is what the Messenger platform expects.
For buttons for example:
As you use the DialogFlow Fulfillment library you want to look at the Payload object.