aws-solutions / qnabot-on-aws

AWS QnABot is a multi-channel, multi-language conversational interface (chatbot) that responds to your customer's questions, answers, and feedback. The solution allows you to deploy a fully functional chatbot across multiple channels including chat, voice, SMS and Amazon Alexa.
https://aws.amazon.com/solutions/implementations/aws-qnabot
Apache License 2.0
399 stars 252 forks source link

The reply of the qna bot is sometimes null/blank (intermittent) #759

Closed dangollayan closed 2 months ago

dangollayan commented 3 months ago

Describe the bug The qna bot sometimes replies a blank reply/ null when using lambda hook. image

To Reproduce Create an agent with knowledgebase/action group as a lambda hook then attached it to no hits intent image

Expected behavior The bot should be able to reply with what the lambdah hook returned

Please complete the following information about the solution:

Screenshots no errors in fulfillment lambda as well image

dangollayan commented 3 months ago

Hi, I've just finished troubleshooting and noticed that if the Lambda hook process exceeds 30 seconds, it returns a blank reply. Can anyone help with this issue?

bobpskier commented 3 months ago

@dangollayan If I'm not mistaken, LexV2 has a 30 second timeout on RecognizeText fulfillment. If the QnABot fulfillment processing exceeds this time (including lambda hook) then LexV2 will timeout the request. I believe there are some default messages that can be configured for this case in LexV2. Also, depending on your lexv2 client, the calls to LexV2 might be able to send in a streaming based request although I'm not sure how QnABot would handle this. I think the default for a timeout can be longer using streaming. I've never experimented with streaming for example from the LexWebUi AWS sample to QnABot but perhaps this would give you a chance to stream some messages while the processing is taking place on the back end lambda hook.

dangollayan commented 3 months ago

@dangollayan If I'm not mistaken, LexV2 has a 30 second timeout on RecognizeText fulfillment. If the QnABot fulfillment processing exceeds this time (including lambda hook) then LexV2 will timeout the request. I believe there are some default messages that can be configured for this case in LexV2. Also, depending on your lexv2 client, the calls to LexV2 might be able to send in a streaming based request although I'm not sure how QnABot would handle this. I think the default for a timeout can be longer using streaming. I've never experimented with streaming for example from the LexWebUi AWS sample to QnABot but perhaps this would give you a chance to stream some messages while the processing is taking place on the back end lambda hook.

thanks for your thoughts @bobpskier!

fhoueto-amz commented 3 months ago

Hi @dangollayan Here is the link to the documentation of the timeout limit https://docs.aws.amazon.com/lexv2/latest/APIReference/API_runtime_RecognizeText.html. We will clarify in our documentation

dangollayan commented 3 months ago

Hi @dangollayan Here is the link to the documentation of the timeout limit https://docs.aws.amazon.com/lexv2/latest/APIReference/API_runtime_RecognizeText.html. We will clarify in our documentation

hi @fhoueto-amz, can you elaborate how can we configure the time out to QNA bot setup?

As per checking the document, it has this image

michaelin-96 commented 2 months ago

@dangollayan

I would start here for the Lex API reference docs: https://docs.aws.amazon.com/lexv2/latest/dg/streaming-progress.html#progress-updates. Seems like you can specify a timeout length of up to 15 minutes (900 seconds)

dangollayan commented 2 months ago

@dangollayan

I would start here for the Lex API reference docs: https://docs.aws.amazon.com/lexv2/latest/dg/streaming-progress.html#progress-updates. Seems like you can specify a timeout length of up to 15 minutes (900 seconds)

Doesn't work with the solution

abhirpat commented 2 months ago

Hi @dangollayan ,

To answer your questions, I'd suggest to try post-processing lambda hook and examine the input event to the lambda. In that input event, you can modify sessionState as needed to set timeToLive. Before implementing this solution, you will want to evaluate if there is negative impact of this change in terms of concurrency and lambda 15 min timeout .

For more information on post-processing lambda hooks, please see Lambda Hooks

Best, Abhishek

abhirpat commented 2 months ago

Hi @dangollayan, I'll go ahead and archive this for now but please feel free to let me know if any follow-up questions on the approach I mentioned above.

dangollayan commented 1 month ago

@dangollayan If I'm not mistaken, LexV2 has a 30 second timeout on RecognizeText fulfillment. If the QnABot fulfillment processing exceeds this time (including lambda hook) then LexV2 will timeout the request. I believe there are some default messages that can be configured for this case in LexV2. Also, depending on your lexv2 client, the calls to LexV2 might be able to send in a streaming based request although I'm not sure how QnABot would handle this. I think the default for a timeout can be longer using streaming. I've never experimented with streaming for example from the LexWebUi AWS sample to QnABot but perhaps this would give you a chance to stream some messages while the processing is taking place on the back end lambda hook.

Tried the lex web UI streaming, it works like chat gpt, but the still the cap is 30 seconds

dangollayan commented 1 month ago

Hi @dangollayan ,

To answer your questions, I'd suggest to try post-processing lambda hook and examine the input event to the lambda. In that input event, you can modify sessionState as needed to set timeToLive. Before implementing this solution, you will want to evaluate if there is negative impact of this change in terms of concurrency and lambda 15 min timeout .

For more information on post-processing lambda hooks, please see Lambda Hooks

Best, Abhishek

Hi @abhirpat,

Thanks for examining my problem, sorry but I don't get your point. Are you suggesting that instead of using utterance lambda hook, I should my lambda to post-process lambda hook?

abhirpat commented 1 month ago

Hi @dangollayan Sorry, I don't recall having a discussion about Utterance Lambda in this thread. Perhaps you were discussing it in other threads.

Regarding your question on modifying sessionState, I recommended exploring post-processing lambda hooks to modify the request as per your needs. If you haven't had a chance to explore lambda hooks before, I'd recommend exploring both pre-processing and post-processing lambda hooks. You can set these up and log the input event to these lambdas to see which keys in the request you can access and modify. These lambda hooks give you the flexibility to manipulate the input and output of a chat user's request to QnABot as per your needs.

To learn more on setup about lambda hooks, please see Lambda Hooks.