简体   繁体   中英

How use api.ai + webhook + lambda

I am in the development of a chatbot and I am doing tests of how to gear the technologies to use. My thought is to use Facebook Messenger linked to API.ai and from API.ai use Webhook to send to Amazon API Gateway + Lambda to perform some tasks with DynamoDB .

My question is in Webhook (this is the first time I use it) if I have a single url ( API Gateway ) associated with API.ai . As I call different Lambda functions when different Intents require it. That is to say:

Intent1 -> API Gateway -> Lambda1

Intent2 -> API Gateway -> Lambda2

I have thought that since it is a single url ( API Gateway ) which can be associated in API.ai . Should a Lambda function be used as a filter?

Intention1 -> API Gateway -> LambdaFilter -> Lambda1

Intention2 -> API Gateway -> LambdaFilter -> Lambda2

I appreciate any help and advices.

Well, I am struggling with this architecture planning as well. You will need a single API entry, and that said, it will point to a specific lambda function.

You can activate "Proxy Integration" for your Lambda, and than you will be able to capture all headers sent from API.ai on fulfillment webhook.

Then, using LambdaFilter (which is a Lambda), you will need to code with boto3 to call other lambdas, and this will add more lambda calls and processing time. Another thing to try (I didnt try yet) is StepFuncions, which claims to solve lambda workflow management.

To illustrate how bad is a lambda calling another one in my tests, I did SLACK > APIGW > LAMBDAs > SLACK. A chain of 4 lambda calls (slack-handler, general-handler, general-notifier, slack-notifier) was taking around .6~.9s. And I still was not calling API.ai!!! Compressing it to only 2 lambdas (handler and notifier, with more complex code in it) got me to a .3~.4s scenario.

I did that to avoid coupling my solution to API.ai or Slack.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM