我得到这个错误,但请求不是空的.
const {
Pedido,
buscaPedidos
} = require('../models/PedidosModel');
const {
WebhookClient,
Payload
} = require('dialogflow-fulfillment');
const { Carousel } = require('actions-on-google');
exports.bot = async (req, res) => {
console.log(req.body);
const agent = new WebhookClient({ req: req.body, res: res });
let conv = agent.conv();
conv.ask(new Carousel({
items: {
// Add the first item to the carousel
[SELECTION_KEY_ONE]: {
synonyms: [
'synonym of title 1',
'synonym of title 2',
'synonym of title 3',
],
title: 'Title of First Carousel Item',
description: 'This is a description of a carousel item.',
image: new Image({
url: IMG_URL_AOG,
alt: 'Image alternate text',
}),
},
// Add the second item to the carousel
[SELECTION_KEY_GOOGLE_HOME]: {
synonyms: [
'Google Home Assistant',
'Assistant on the Google Home',
],
title: 'Google Home',
description: 'Google Home is a voice-activated speaker powered by ' +
'the Google Assistant.',
image: new Image({
url: IMG_URL_GOOGLE_HOME,
alt: 'Google Home',
}),
},
// Add third item to the carousel
[SELECTION_KEY_GOOGLE_PIXEL]: {
synonyms: [
'Google Pixel XL',
'Pixel',
'Pixel XL',
],
title: 'Google Pixel',
description: 'Pixel. Phone by Google.',
image: new Image({
url: IMG_URL_GOOGLE_PIXEL,
alt: 'Google Pixel',
}),
},
// Add last item of the carousel
[SELECTION_KEY_GOOGLE_ALLO]: {
title: 'Google Allo',
synonyms: [
'Allo',
],
description: 'Introducing Google Allo, a smart messaging app that ' +
'helps you say more and do more.',
image: new Image({
url: IMG_URL_GOOGLE_ALLO,
alt: 'Google Allo Logo',
}),
},
},
}));
agent.add(conv);
agent.send(conv);
}
字符串
请求的console.log正在显示
{
responseId: '373f7c26-2802-41fa-8fe6-209bd7037aae-470ed8da',
queryResult: {
queryText: 'quero ver o menu',
action: 'solicitando_cardapio',
parameters: {},
allRequiredParamsPresent: true,
fulfillmentText: 'Desculpe, mas não estamos conseguindo acessar o sistema neste momento...',
fulfillmentMessages: [ [Object] ],
outputContexts: [ [Object] ],
intent: {
name: 'projects/hamburgueria-hw9g/agent/intents/edda994b-0943-4b28-9b17-961f406d5eca',
displayName: 'solicitar_cardapio'
},
intentDetectionConfidence: 1,
languageCode: 'pt-br'
},
originalDetectIntentRequest: { payload: {} },
session: 'projects/hamburgueria-hw9g/agent/sessions/dfMessenger-73173927'
}
型
所以,请求不是空的。。你能帮帮我吗?
我尝试了很多东西,包括问GPT,但GPT没有发现任何问题,这最终的代码。我读了其他stackoverflows的问题,但任何人都解决了这个问题,大多数人都要求做我已经在做的事情:const agent = new WebhookClient({ req:请求正文,res:});
所以,我真的解决不了……
1条答案
按热度按时间qncylg1j1#
尝试以这种方式示例化
WebhookClient
:字符串
如果检查
dialogflow-fulfillment
github源代码,构造函数会验证“request”属性。WebhookClient Constructor