出现问题,试图运行新的AWS/Serverless/Dialogflow项目。我确信这是一件简单的事情,我只是看不到而已。
步骤
serverless create --template aws-nodejs-typescript创建初始项目actions-on-google为了彻底起见,这里是我的serverless.yml。(我手动创建了API网关,因为无服务器创建了lambda代理,而且我还没有查看其他配置。)
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
示例源选择使用猫!
发布于 2018-08-22 15:32:15
终于有了一些时间回到这个问题上,并遇到了这个git发行。
本质上,dialogflow实例需要由lambda封装。
exports.fulfillment = function(event, context, callback) {
app.handler(event, {})
.then((res) => {
if (res.status != 200) {
callback(null, {
"fulfillmentText": `I got status code: ${res.status}`
});
} else {
callback(null, res.body);
}
}).catch((e) => {
callback(null, {
"fulfillmentText": `There was an error\n${e}`
});
});
};https://stackoverflow.com/questions/50865741
复制相似问题