DialogflowRichResponseFromWebhook
const express = require('express');
const app = express()
app.use(express.json());
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(3000, () => console.log('Example app listening on port 3000!'))
// POST method route
app.post('/', function (req, res) {
console.log(req);
let action = req.body.queryResult.action;
console.log(action);
let responseJson = {};
responseJson.fulfillmentText = 'This is an endpoint published to RunKit'; // displayed response
if(action === 'telegram.quickreply'){
let richResponses = [
{
"quickReplies": {
"title": "This is a reply from RunKit. Choose an option",
"quickReplies": [
"YES",
"NO"
]
},
"platform": "TELEGRAM"
}
]
responseJson.fulfillmentMessages = richResponses;
}
else if (action === 'facebook.card'){
console.log('Inside facebook.card if condition');
let richResponses = [
{
"card": {
"title": "Card Title",
"subtitle": "Card subtitle",
"imageUri": "https://github.com/fluidicon.png",
"buttons": [
{
"text": "Go to Google",
"postback": "www.google.com"
},
{
"text": "Go to Dialogflow",
"postback": "www.dialogflow.com"
},
{
"text": "Go to Slack",
"postback": "www.slack.com"
}
]
},
"platform": "FACEBOOK"
},
{
"text": {
"text": [
""
]
}
}
]
responseJson.fulfillmentMessages = richResponses;
console.log(responseJson);
}
res.json(responseJson);
})
no comments