How Do I Get An Authorized User For Posttext Api Call For A Lex Bot Runtime
Solution 1:
The userID
of PostText
is the way you persist the conversation back and forth between the user and Lex. It can be anything that you can identify the user by in their incoming request that is consistent and unique to them, at least for that session.
From AWS PostText Docs:
userID The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. At runtime, each request must contain the userID field. ... Length Constraints: Minimum length of 2. Maximum length of 100. Pattern: [0-9a-zA-Z._:-]+
So if a user is using Facebook messenger, they will have a Facebook ID that is passed with their messages and you can use that as their userID
.
If a user is using Twilio-SMS, they will have a phone number passed with their messages and you can use that as their userID
.
Your code is currently taking event["RecipientID"]
and using that as a userID
. But the RecipientID
from an incoming message is yourself, the receiver of the incoming message.
Your error is telling you that
... User: arn:aws:sts::XXXXXXXXXX:assumed-role/lambda_basic_execution/OrchestratorAPIApp
So the userID
= event["RecipientID"]
= 'arn:aws:sts::XXXXXXXX:assumed-role/lambda_basic_execution/OrchestratorAPIApp'
You definitely don't want the Recipient ID to be used.
Instead you want the sender's ID to be the userID
. Something like:
userId = event["SenderID"]
That might not be the exact code you use, its just an example. You should be able to view the incoming request, and locate something in there to use as a proper userID as I explained above with Facebook and Twilio.
Post a Comment for "How Do I Get An Authorized User For Posttext Api Call For A Lex Bot Runtime"