У меня есть серверное приложение, в котором я хочу запустить свою логику из запроса чат-бота, поступающего из Facebook Messenger. Когда я запускаю функцию намерения для test_handler , я получаю правильный ответ. Но после того, как я добавил другой обработчик для skillRatio , мне кажется, что я получаю ошибку в заголовке, т.е.
Ошибка: платформа не может быть пустой при новой полезной нагрузке
. Мой код, как показано ниже.
const serverless = require('serverless-http');
const bodyParser = require('body-parser');
const express = require('express');
const app = express();
app.use(bodyParser.json({ strict: false }));
const {WebhookClient, Payload, Image, Card, Suggestion} = require('dialogflow-fulfillment');
const request = require('request');
app.get('/', function (req, res) {
res.send('Hello World !!!\n');
console.log("Testing express lambda\n");
})
app.post('/', function (req, res) {
const agent = new WebhookClient({request: req, response: res});
function test_handler(agent) {
agent.add(`Welcome to my agent on AWS Lambda!`);
agent.add(new Image("https://image-charts.com/chart?chs=700x190&chd=t:60,40&cht=p3&chl=Hello%7CWorld&chf=ps0-0,lg,45,ffeb3b,0.2,f44336,1|ps0-1,lg,45,8bc34a,0.2,009688,1"))
}
function skillRatio(agent) {
agent.add(`Let me just have a look and I'll gather the data. *Processing Chart Data....Mmmm Pie*.
Here we go! Here is the data on your $Skills.original request.`);
//agent.add(`Feel free to save or share :)`);
//agent.add(new Image("https://image-charts.com/chart?chs=700x190&chd=t:60,40&cht=p3&chl=Hello%7CWorld&chf=ps0-0,lg,45,ffeb3b,0.2,f44336,1|ps0-1,lg,45,8bc34a,0.2,009688,1"))
}
// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('super-test', test_handler);
//intentMap.set('skill-ratio', skillRatio);
if (agent.requestSource === agent.FACEBOOK) {
intentMap.set('super-test', test_handler);
intentMap.set('skill-ratio', skillRatio);
} else {
}
agent.handleRequest(intentMap);
})
module.exports.handler = serverless(app);
Изображения Dialogflow:
Я пытаюсь запустить код в Messenger. Буду очень признателен за любую помощь, потому что я так застрял, пытаясь разобраться с этим.