I am trying to migrate a bot from microsoft azure to aws lex. In azure we can use multiple session.send() statements to send multiple responses to a single user input. But in aws lex we can not use multiple return statements in lambda function.
In my azure bot I am sending a response after every 5 minute to the user. e.g:-
var myVar = setInterval(myTimer, 300000);
function myTimer() {
session.send(message);
}
How to achieve this in aws lex using lambda function.?
You won't be able to trigger a second response from a "post-Lex" Lambda, meaning a Lambda Function that comes after Lex. You would need a "pre-Lex" Lambda Function that passes the user input to Lex and returns Lex responses back to the user.
This is the basic set up of a Lex bot:
But this is how you would need it set up:
It doesn't actually need to be a Lambda Function between the user and Lex but either way, it will need to use Lex Runtime Service API with PostContent or PostText to pass the userInput
to Lex.
Here's an Amazon blog on how they used Lambda this way, in what they call a "pre-processing layer" between a channel and Lex: Integrate Your Amazon Lex Bot with Any Messaging Service
You'll see that they also use AWS API Gateway to create an HTTPS endpoint in order to connect the user's channel to this "pre-processing" Lambda.
After setting up any type of "pre-processing" layer, it is in there that you can get around Lex's limitations on responses and would only have to worry about the channel's limitations.
Friendly Warning: I believe Amazon has set up these limitations in Lex to discourage chatbot developers from spamming users, and when you say "I am sending a response after every 5 minute to the user", it definitely sounds like it could become spam. So be careful with that.