Open URL in same tab and not new window
https://github.com/Microsoft/BotFramework-WebChat/blob/617de0a0145aef1f2843c72d7ec4e6818c0bf7fb/src/Chat.tsx#L321
Currently, openUrl will open in new window (using window.open).
@compulim you are right "Currently, openUrl will open in new window (using window.open)" but I want to open url into current tab/page of browser this is a query. Its like enhancement into WebChat.
I am looking for this feature too. If you want your chatbot to help you with page navigation by links this is a necessary feature. Opening in a new tab will destroy the navigation workflow.
I'm trying to solve this myself. How to open in a new tab without losing the flow of conversation.
Is there any way that if the chat opens in several tabs within the same browser, keep the conversationID?
Hey guys Solution here https://stackoverflow.com/questions/50444463/azure-bot-c-sharp-webchat-open-url-in-same-tab-of-browser-its-opening-in-new
Thanks everyone.
I have added this as a planning item for customizability, we are planning some big works over there
@serpino you will need to look inside directLine props, you may want to go over this issue. In short, it's more on the DirectLineJS side, than on Web Chat side. But we own both anyway.
I have been able to solve it by keeping the conversationID in a localstorage when it is a new conversation. If when opening the chat again in that browser there is a localstorage with that conversationID, I connect with directLine in another way to recover the previous conversation.
Thank you
@serpino Can you please provide some code for doing that?
@Snekha-Shivakumar I detail it step by step When a botchat object is started, an ID is generated.
This is the one we will use to see if it is a new connection or we must retrieve the messages for that conversation.
The first thing you should do is check if there is any cookie or localstorage with that conversartionID I use a function like this:
function ReadLocalStorage(key){
var object = localStorage.getItem(clave);
//Compruebo cuando se creó la cookie. Si ha pasado mas de un dia la elimino
if(object !=null){
var content = jQuery.parseJSON(object);
return content.value;
}
}
In case of not existing, you create the botchat object and with the following function and the conversationID that is generated, you create the localstorage
function CreateLocalStorage(key, value){
var object = {value: valor, timestamp: new Date().getTime()};
//Se crea el storage con los datos del valor y la fecha de creacion
localStorage.setItem(clave, JSON.stringify(object));
}
If it exists, you must create the botchat object with the conversationID that you had saved in the localstorage. This is what you are going to do is retrieve the chat messages for that ID, so when you change the tab you will have them.
With this conversationID you must make a request as explained in the following link, and you will receive the necessary parameters to create the botchat object
https://docs.microsoft.com/es-es/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-reconnect-to-conversation?view=azure-bot-service-3.0
Related to https://github.com/Microsoft/BotFramework-WebChat/issues/368, please refer to that issue for tracking.