0

I am connecting slack to an api gateway that triggers a lambda function. In the slack api spec it says that events must have a 2XX response within 3 seconds so it is best to handle sending the response to the event and the 2XX confirmation of receival response separate. The solution I am thinking about right now would be to have an automatic 200 response from the api gateway when an event is received and also trigger a lambda function that could use the slack api to respond. Is it possible to trigger a lambda function and have a different response that can be sent before the lambda is done executing?

A possible solution I have thought of is having a lambda function that returns 2XX receival response and then this lambda will call another lambda to send the actual response. Is this the best solution?

PDPDPDPD
  • 445
  • 5
  • 16
  • The best solution depends on your requirements. In general I would suggest to put all incoming events in a queue.and return 200 OK. Then have a queue worker process to handle the actual events. – Erik Kalkoken Jul 01 '19 at 22:00
  • Sorry this might be a stupid question but how would I go about putting events into a queue. Is this a feature of gateway? – PDPDPDPD Jul 01 '19 at 23:14
  • There are many options. e.g. you can use the queue feature of asyncio in Pyhthon, or Amazons SQS service – Erik Kalkoken Jul 02 '19 at 11:08
  • another more simple approach is to just spawn a new process in Python for every event you receive. Let you original process send OK 200 and terminate and continue processing with the spawned process. see this for more: https://stackoverflow.com/questions/48994440/execute-a-function-after-flask-returns-response/51013358 – Erik Kalkoken Jul 02 '19 at 11:11

0 Answers0