Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Dialogflow ES: Keeping session open while user is visiting multiple pages on a site

I'm working on a project using Dialogflow ES.  When testing on the site, I see that a Dialogflow session lasts as long as a user is on the same page.  If a user navigates to a different page on the site, the Dialogflow session resets and the user can't see the history of the conversation.  Is there a way to keep a Dialogflow ES session open as long as the user is on the site domain so he/she can navigate the site while interacting with Dialogflow?

0 6 1,084
6 REPLIES 6

Good day @fogpuddle ,

Welcome back to Google Cloud Community!

You can try using the Dialogflow Messenger to maintain the users session, you can embed a code to your page and it will create a session ID that can be used to keep the users progress, so while the user are navigating the site, their progress are saved and the user can continue the conversation. You can learn more here: https://cloud.google.com/dialogflow/es/docs/integrations/dialogflow-messenger

Hope it helps!

Thanks for your feedback @kvandres.

We do use the embed code of Dialogflow Messenger on the site and I notice that if we don't have a session-id defined in the code, Dialogflow creates a unique one.  However, it creates a unique one for every page, thus restarting the conversation on every page visit.

I'm reading in the documentation that if we want a session id throughout the site domain visit, a session id would have to be created by our system and then supplied to Dialogflow via a "detect intent request."  However, we're not connected to any APIs that involves a detect intent request for our build.  Is this a requirement or can the session ID just be supplied in the Dialogflow Messenger embed code to keep the session open throughout a user's site visit? 

Hi, @fogpuddle @kvandres Dialogflow Es, create the session when the first intent is triggered, In the case of Web is the welcome event that triggers it.

  • The session will reset if the webpage is reloaded.
  • if you keep messaging the chatbot in a gap of 20 minutes, the session will stay.

In the case you want a user to have a session (You can do this workaround, probably isn't the best but I dont see other solutions)

From your frontend code, create the first intent add attach it a value, a parameter, then when users hits a button, send that parameter as an entity, and catch as Session_id, then you can use handlers per each context to make the bot show the last process or message (if not completed by the user)

 

Hope that Helps

@kvandres Let me know if you have any questions about my above response.  I'm trying to find a solution to keep a chatbot session open while a user navigates various pages on our site.  Right now, the chatbot restarts on every page visit while on our site domain.  We have the Dialogflow Messenger embed code in the footer of the site.  Is there a way to keep the session open for an anonymous user while the user is clicking from page to page on our site? 

Hi @fogpuddle I am having the same issue of session ending between pages on my site. Did you get a chance to resolve it? If so, can you kindly share? Thank you!

Sorry @laux, I did not come up with a solution around this.  Creating and managing a session id outside of Dialogflow to insert into the Dialog Messenger embed code was out of scope for the project I was working on.