【发布时间】:2018-08-22 23:32:15
【问题描述】:
在尝试运行新的 AWS/Serverless/Dialogflow 项目时遇到问题。我确信这很简单,我只是没有看到。
步骤
创建初始项目使用:
serverless create --template aws-nodejs-typescript将 handler.js 移至 src/ 并更新了 serverless.yml
- npm 已安装
actions-on-google -
遵循actions-on-google 示例并更新了src/handler.js
import { dialogflow, Image } from 'actions-on-google'; const app = dialogflow({debug: true}); app.intent("test.intent", (conv) => { conv.ask("Hi, how is it going?"); conv.ask("Here is a picture of a cat!"); conv.ask(new Image({ url: "https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/imgs/160204193356-01-cat-500.jpg", alt: "A fluffy cat!" })); }); exports.fulfillment = app; -
还更新了 tsconfig.json 以匹配另一个 Typescript 项目
{ "compilerOptions": { "sourceMap": true, "target": "es6", "allowJs": true, "module": "commonjs" }, "exclude": [ "node_modules" ], "include": [ "./src/**/*" ] }
为了彻底,这里是我的 serverless.yml。 (我手动创建了 API 网关,因为 serverless 创建了 lambda-proxy,而我没有查看其他配置。)
service:
name: test-lambda
# Add the serverless-webpack plugin
plugins:
- serverless-webpack
provider:
name: aws
runtime: nodejs6.10
functions:
fulfillment:
handler: src/handler.fulfillment
# events:
# - http:
# method: get
# path: hello
错误
项目编译和部署成功,但是当调用 lambda 时,我不断得到
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot convert undefined or null to object
附:示例源选择使用猫!
【问题讨论】:
-
我不认为你可以在没有additional plumbing 的情况下将处理程序设置为快速应用程序。你已经read this了吗?
-
@Mike Patrick 谢谢,但该信息适用于 Dialogflow V1,它需要将请求/响应传递到库中。最终,我会将我的 V1 项目迁移到 V2,只需要弄清楚这一点。
标签: amazon-web-services dialogflow-es serverless-framework