Search code examples
dialogflow-es

Can we use same session_id for particular user in dialogflow?


we have detect_intent function in Dialogflow python client to detect the intent of a particular text wherein we need to pass session which is created using session_id. I use a function to generate a hashed session_id for a particular end-user. Can I pass the same session_id every time I call detect_intent? In docs, they say the session is valid for 20 mins, so if I use the same session_id, will it be a new session?


Solution

  • Please see this excellent answer on Dialogflow Session length. Short answer - there's nothing to stop you re-opening the session after 20 minutes by using the same session ID, but all the contexts (which are the only thing that really matter as far as sessions are concerned) will have dropped off. You must also save the contexts to your database to re-initialise Dialogflow to pick up where you left off.

    It's worth noting however that you probably don't need to (and shouldn't) do this for almost all use-cases.