Tôi đang cố gắng gọi webhook từ luồng thoại và không nhận được phản hồi từ webhook, phản hồi tôi nhận được từ phần phản hồi, đã đưa vào ý định. Tôi cũng đã bật webhook cho mỗi mục đích và cũng đặt URL webhook, được tạo từ CLI Firebase trong phần URL hoàn thành. Tôi gắn các ảnh chụp màn hình của nhật ký firebase và phản hồi JSON mà chúng ta thấy trong luồng thoại "hiển thị JSON" và tệp index.js. Tôi bị kẹt trong 2 tuần để giải quyết nó.nhận được lỗi "Lỗi hành động: không có trình xử lý mục đích phù hợp cho: null" khi truy cập URL webhook
'use strict';
process.env.DEBUG = 'actions-on-google:*';
const { DialogflowApp } = require('actions-on-google');
const functions = require('firebase-functions');
let express = require('express');
let bodyParser = require('body-parser');
// Constants for Dialogflow Agent Actions
let app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json({type: 'application/json'}));
const BYE_RESPONSE = 'input.search';
const WELCOME = 'input.welcome';
exports.helloAssistant = functions.https.onRequest((req, res) => {
console.log('Request headers: ' + JSON.stringify(req.headers));
console.log('Request body: ' + JSON.stringify(req.body));
const asst = new DialogflowApp({request: req, response: res});
// Welcome
function welcome(asst) {
asst.ask('Want to search product or order history');
asst.tell('hello Neeraj!');
}
// Leave conversation with SimpleResponse
function byeResponse (asst) {
app.post('/',function (req, res) {
var myProduct = req.body.result.parameters["productParameter"];
//let intent=asst.getIntent();
var address ="https://ipadress/rest/v2/electronics/products/search";
var address1="https://ipadress";
switch(myProduct){
case 'BYE_RESPONSE':
req.post(address);
break;
case 'WELCOME':
asst.tell('welcome!');
break;
default:
req.post(address1);
break;
}
asst.tell('We swear to serve the master of the Precious.');
});
}
const actionMap = new Map();
actionMap.set(WELCOME, welcome);
actionMap.set(BYE_RESPONSE, byeResponse);
actionMap.set(WELCOME, welcome);
asst.handleRequest(actionMap);
});
Bạn có thể thêm ảnh chụp màn hình của input.search Ý định của bạn và input.welcome Ý định từ Dialogflow? – Prisoner
đây là url hình ảnh của các ý định của tôi –
đây là url hình ảnh của các ý định của tôi từ Dialogflow. 1. https://imgur.com/a/NcM4z 2. https://imgur.com/a/NcM4z 3.https: //imgur.com/a/NcM4z 4. https://imgur.com/a/NcM4z –