BotFramework-WebChat icon indicating copy to clipboard operation
BotFramework-WebChat copied to clipboard

Open URL in same tab and not new window

Open RohitMane opened this issue 8 years ago • 10 comments

https://github.com/Microsoft/BotFramework-WebChat/blob/617de0a0145aef1f2843c72d7ec4e6818c0bf7fb/src/Chat.tsx#L321

RohitMane avatar May 21 '18 06:05 RohitMane

Currently, openUrl will open in new window (using window.open).

compulim avatar May 21 '18 20:05 compulim

@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.

RohitMane avatar May 22 '18 06:05 RohitMane

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.

rafaelmaeuer avatar May 25 '18 08:05 rafaelmaeuer

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?

serpino avatar May 29 '18 12:05 serpino

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.

compulim avatar Jun 14 '18 08:06 compulim

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 avatar Jun 14 '18 08:06 serpino

@serpino Can you please provide some code for doing that?

Snekha-Shivakumar avatar Aug 28 '18 11:08 Snekha-Shivakumar

@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

serpino avatar Aug 28 '18 12:08 serpino

Related to https://github.com/Microsoft/BotFramework-WebChat/issues/368, please refer to that issue for tracking.

corinagum avatar Nov 29 '18 18:11 corinagum