node.js - 为什么我在 Lambda 上得到“未检测到对话流意图”,但它在 Google Cloud Functions 上运行良好?
问题描述
我正在构建一个 Dialogflow 代理,并将实现代码从 Google Cloud Functions 迁移到 AWS Lambda。这是入口代码:
'use strict';
/* CONSTANTS AND GLOBAL VARIABLES */
const functions = require('firebase-functions');
const { dialogflow } = require('actions-on-google');
const app = dialogflow({ debug: true });
const intents = require('./intentsController.js');
app.middleware(conv => {
conv.hasScreen =
conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT');
conv.hasAudioPlayback =
conv.surface.capabilities.has('actions.capability.AUDIO_OUTPUT');
});
app.intent('Welcome Intent', intents.welcomeIntent)
/* INTENT HANDLERS */
app.intent('Default Fallback Intent', intents.fallBackIntent);
app.intent('Find Multiple Posts Intent', intents.multiplePostsIntent);
exports.testFunction = functions.https.onRequest(app);
从 Lambda 查看 cloudwatch 日志时,我收到此错误:
"errorType": "Runtime.UnhandledPromiseRejection", "errorMessage": "错误:未提供意图并且未定义回退处理程序。",
在 AWS 与 Google Cloud 上查看请求时,AWS 看起来像是将请求正文中的 JSON 作为字符串保留。为什么这在 Lambda 上会有所不同,我在这里做错了什么?
解决方案
事实证明我使用了错误的 API Gateway 类型。当我应该使用 REST API 时,我正在创建一个 http API。切换到 REST 解决了这个问题。
推荐阅读
- node.js - 邮递员 401 未经授权 | 不能获取
- spring - Spring Boot 自定义查询 MongoDB
- android - 为什么我的 Android Studio (Kotlin) 在 Preview 中显示 Android 手机的布局,但在 Build App 中没有?
- javascript - 使用 Angular 6 中的拖放创建动态 UI?
- java - 将多个 MySql 数据库连接到应用程序
- actions-on-google - google actions sdk:声音的动态变化
- autodesk-forge - 邮递员和卷曲的伪造请求失败
- nsurlconnection - 我想加载图像使用 NSURLConnectionDelegate 和 NSURLConnectionDataDelegate 的方法
- tags - 在登录页面的导航栏中使用类别标签
- sql-server - 普遍数据库的架构图