I have a basic chat bot using Amazon Lex that asks the users some questions which then takes those answers and sends them to the fulfilment Lambda function to process it.
Before the Lambda function is triggered, I would like to display a message to the chat window stating the request is being processed as it could take up to a minute to process the request.
I would like to display a message such as "Thank you, your request is being processed" instead of waiting up to a minute for a response from the Lambda function.
Is this something that is possible via Lex?
Many thanks.
Related
I have a Lex bot whose fulfillment is set to my Lambda function (LF1), so everytime the intent is fulfilled, LF1 will be triggered and the slots parameters will be sent to LF1, which sends the data to SQS and then processed and send text msg via SNS. It works, but every time I finished the conversation with my bot, my phone receives two messages at the same time. After a careful look at CloudWatch, I found the LF1 was triggered twice every time the intent is fulfilled. They have the same message, but different request-id and different message-id. I really couldn't figure out where goes wrong. Please help!
lambda function log
detail of the first trigger
detail of the second trigger
My Lex bot has four intents. Suppose a user asks a question at the very beginning of the conversation and this question is not allotted to any of the four intents. Hence no intent will be established. When this happens, I want to call lambda to run an "intent suggestion model" (built using topic modeling) to suggest the user about what the intent of the question might be. Also, lambda will have to store such queries in a database (s3 or RDB) so that if such queries are repetitive, then that intent can eventually be added to the bot and for other analytical solutions.
What you need is a fallback intent but Lex does not support fallback intents as of now.
You can still achieve this if you use a bridge between your chat client and Lex.
Setup an API Gateway and Lambda function in between your chat-client and the Lex.
Your chat-client will send a request to API Gateway, API Gateway will forward this to Lambda function which will be used to call Lex and get response from it. Lex will have one more lambda function as a webhook.
In the Lambda function you used to call Lex, we can check if any intent was matched or we got an error message, if it's an error message and trigger some action like intent suggestion model.
You need to use boto library to call Lex and use post_text() method.
Hope it helps.
I want to write a Lambda Handler in JAVA to read the events of CloudWatch. These Events are coming from Media Convert API.
Steps that I covered:
Configured the eclipse using AWS tool Kit.
Created an AWS Project with a Lambda function.
Doubt begin from here:
Which Event type shall I select to make a Lambda Handler as it is showing following options:
S3, SNS, Custom, Stream Request Handler, Kinesis Event, Cognito Event.
Note: No mention of Elemental Media Convert type event that are written over CloudWatch Stream.
What is Stream Request Handler here? Does it a handler that could be configured to listen Event stream based event. Is it So. If Yes, Kindly help me to figure out this one.
Added Flow:
A) Media Convert service is used to change format of submitted media.
b) Documentation states that All events are published on Event stream of CloudWatch, when job status changes.
C) Here, i want to read these events from Event stream of Cloud watch regarding change in job status.
You can write a small Lambda function that prints the incoming event to the log file:
def lambda_handler(event, context):
print (event)
return
Then, trigger the function via CloudWatch. The function will write the event to the log files. You can examine the logs to see what information was passed into the function.
This will show you the real content of the message. The other message types are simply for testing in case you do not have a trigger setup to create a real event.
I've created a lex sms chatbot and published it to a Twilio SMS Channel. Within my java lambda fulfillment handleRequest function I receive 2 parameters: an Input object and a Context. Input has some type of system generated userId, but I need the phone number of the incoming sms message from Twilio.
I've configured Twilio to call Lex via webhook per these instructions:
http://docs.aws.amazon.com/lex/latest/dg/twilio-bot-association.html#twilio-bot-assoc-create-assoc
I'm using the system created webhook callback url between Lex and Twilio and would like to avoid writing my own Lex-Twilio go between with Gateway API and lambda if possible.
I think I'm missing a configuration in Twilio to send this to Lex maybe? I haven't setup any TwilML app or anything, just linked the SMS number to my webhook callback url for lex. Everything works fine except getting the incoming sms number.
UPDATE:
I exhausted all possibilities with my input object and context in my java lambda function. I guess there's no way to get at the payload from twilio in Java. I tried switching to an input stream handler but still only had the input format defined in the documentation here: http://docs.aws.amazon.com/lex/latest/dg/lambda-input-response-format.html
I had to bite the bullet and build my own gateway API and Node handler. It's just a layer that sits before lex and translates twilio into lex input format and vis versa on the response. It updates the userId with the incoming phone number.
This tutorial was very useful in doing this:
https://aws.amazon.com/blogs/ai/integrate-your-amazon-lex-bot-with-any-messaging-service/
It was a lot of work just to get one additional field, but It does provide me the flexibility to switch SMS providers in the future easier.
I am not sure as what exactly stopped you from getting the user phone number in your lambda function. You can always get sender phone number from 'userId' field from the input event in your lambda function. You can refer to the documentation to get more information.
I set the MX records for my domain to the ones AWS provides for receiving emails with SES.
Now I want to process incoming emails via Lambda function.
To be more specific, I would like to scan the message body for certain keywords and perform a task based on this.
Does the lambda function get the email body? When looking through the event variable, I could only find a subject line.
All examples I found went to S3 to get the message body. Does the body really not get sent to Lambda and it is necessary to fetch it via S3?
Message bodies can get very large. That's why you need to download them from S3.