keep the session after response in lex

993 views Asked by At

I'm creating as AWS Lex chatbot with this flow: The user starts saying open my bot and there are a couple of questions asked by Lex, the user has to respond to them and finally a number is generated and this is the Fulfilled slot.

Here is my code:

if (source === "DialogCodeHook") {
    if (!sessionAttributes.isFlowDone) {
    //multiple questions asked and managed by using Elicit Slots
    //once the questions are complete I set sessionAttributes.isFlowDone=true;
} else {
    sessionAttributes.isFlowDone = false;
    callback(close(intentRequest.sessionAttributes, "Fulfilled", buildMessage(finalMessageWithANumber)));
}

The issue is that, while testing in the AWS Lex chat window, when the number is generated, if you clear the console and type in open my bot, the questions are once again asked and the flow is done as a new request, What I want is that after building the randomNumber, I ask again open my bot without clearing the chat window, it gives me another number instead of asking me the questions (directly the fulfilled callback is called). please let me know on how can I fix this and continue my flow.

1

There are 1 answers

2
Saurabh On

Console uses a random user-id (that is sent in PosText/PostContent API) when you test the bot in console chat window. On clicking the 'clear' button console generates another random user-id. Also a bot session is associated with a user-id, so clicking the 'clear' button provides an experience like a new user is talking to the bot (hence all questions are asked over again). Hope this answers your question.