首页 > 解决方案 > 为什么我在 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 上会有所不同,我在这里做错了什么?

标签: node.jslambdagoogle-cloud-functionsdialogflow-es

解决方案


事实证明我使用了错误的 API Gateway 类型。当我应该使用 REST API 时,我正在创建一个 http API。切换到 REST 解决了这个问题。


推荐阅读