scheduling a AWS lex intent as push notification.

0

Hai There,

i have a requirement to schedule a lex intent with pinpoint push notification. consider this example everyday morning at 9 AM i would like to send a push notification to some users for a survey which will have some questions to answer which is a lex and lambda integration.

currently i am able to work with lex by calling the utterance, but what i want to achieve is connect to lex without user calling the utterance. we can think of it like a bot first kinda conversation.

Thanks for the help in advance, charith v.

1 Answer
2

In order to start a conversation without specific user input you can leverage PutSession API. PutSession API creates a new session or modifies an existing session. In this case if you have ability to make a PutSession call as soon as the user clicks on notification that might be a possible approach for you.

PutSession API is supported both in Lex V1 and Lex V2. In Lex V2 to achieve this, you can set the intent in session state and Lex will respond with appropriate next response. You can then play/print that response back to the user continuing subsequent conversation from that point.

Example PutSession Input:

{
    "sessionState": {
        "dialogAction": {
            "type": "Delegate"
        },
        "intent": {
            "name": "BookCar"
        }
    }
}

In this case I am setting 'BookCar' as the current intent and Delegating the next step to Lex. In response header I get the bot response as x-amz-lex-messages

Saket
answered 2 years ago
  • Hai @Saket, Thanks for the response which was really helpful for me to understand that we can invoke conversation via a HTTP API. i am using lex v1 so searching around docs i found that this is the endpoint https://runtime.lex.eu-central-1.amazonaws.com and https://docs.aws.amazon.com/lex/latest/dg/API_runtime_PutSession.html these are the docs. But when i try to invoke the api endpoint i get {"message":"Missing Authentication Token"} i am unable to find where to get and use Authentication token for LEX. And another question i have is is there any way to invoke this via amplify on ReactNative?

  • To make REST API calls you must sign the request with appropriate authentication data. More detail on this is documented at Signing and authenticating REST requests. To ease your testing you can use tools like Postman which will make it easier to sign and manage the auth tokens.

    Regarding integration with Amplify: I personally do not have experience with it so cannot comment on feasibility. But I will suggest you to checkout into Lex JavaScript SDK and if that can be integrated within your ReactNative app. Good Luck!

  • Thanks @Saket, I have opened a new discussion on aws-amplify's repo https://github.com/aws-amplify/amplify-js/discussions/9472

  • Hello, just wanted to follow up and ask if there was any other assistance that we could provide. Otherwise, if you found Saket's answer useful, could you please mark it as the "Accepted Answer". This will benefit others facing similar issues.

    Alternatively, if you need additional assistance, we can help answer Lex specific questions.

    Thank you.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions