How to set context in AWS Lambda handler?
See original GitHub issueMy code works fine with this code:
const {dialogflow} = require('actions-on-google');
const app = dialogflow();
// bunch of app.intent()
exports.handler = app;
Now I want to set context.callbackWaitsForEmptyEventLoop
in AWS Lambda handler function in order to make my backend code work, and I did some search and tried this:
const {dialogflow} = require('actions-on-google');
const app = dialogflow();
// bunch of app.intent()
exports.handler = async function(event, context) {
logger.info("got event: " + event)
context.callbackWaitsForEmptyEventLoop = false;
try {
let body = JSON.parse(event.body);
let headers = event.headers;
let response = await app.handler(body, headers)
logger.info(response)
return response
} catch (err) {
logger.info("err: " + err)
}
};
The code above provides a good response, but dialogflow received the following:
Webhook call failed. Error: 502 Bad Gateway
The documents only give the line exports.fulfillment = app
which is not informative about how to set the content inside.
Can someone please help me with this? Any help is appreciated.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
AWS Lambda context object in Python
When Lambda runs your function, it passes a context object to the handler. This object provides methods and properties that provide information about...
Read more >Chapter 2: What is the event & context?
context is a Python objects that implements methods and has attributes. It's main role is to provide information about the current execution environment....
Read more >What are event and context in function call in AWS Lambda?
Context Provides information about the invocation, function, and execution environment of your lambda. So you can use this to check the memory ...
Read more >Add types to your AWS lambda handler - Xolvio
Lambdas handlers can be invoked with many different, but always complex, event arguments. Add to that the context, callback, matching return type and...
Read more >Add Context for AWS Lambda - Sentry Documentation
The best practice to attach custom data is via structured contexts. A context must always be a dictionary or map, and its values...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try to see if this works:
Hi @luomanke currently that code isn’t implemented yet in the library. You would have to use something like
The code in the documentation is for if you have AWS Lambda API Gateway/HTTP Proxy integration enabled.