gpt4 book ai didi

json - 访问 webhook URL 时出现错误 "Action Error: no matching intent handler for: null"

转载 作者:搜寻专家 更新时间:2023-10-31 22:18:27 24 4
gpt4 key购买 nike

我正在尝试从对话流中调用 webhook,但没有从 webhook 获得响应,这是我从响应部分获得的响应,这是我有意为之的。我还为每个意图启用了 webhook,并将从 firebase CLI 生成的 webhook URL 放在 fulfillment URL 部分。我附上了我们在对话流“显示 JSON”和 index.js 文件中看到的 firebase 日志和 JSON 响应的屏幕截图。我被困了 2 周来解决它。

'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);
});

. json response in dialogflow

. firebase log

最佳答案

我刚刚遇到了这个完全相同的错误,这是因为我忘记将我的意图名称放在 Enter action name 中引起的Actions 的领域部分。

所以,它正在传递 null作为意图名称,因为我没有指定。

我只是通过非常仔细 重读才弄明白 https://developers.google.com/actions/dialogflow/first-app .

关于json - 访问 webhook URL 时出现错误 "Action Error: no matching intent handler for: null",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47555817/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com