Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open URL in same tab and not new window #984

Closed
RohitMane opened this issue May 21, 2018 · 10 comments
Closed

Open URL in same tab and not new window #984

RohitMane opened this issue May 21, 2018 · 10 comments

Comments

@RohitMane
Copy link

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

@compulim
Copy link
Contributor

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

@RohitMane
Copy link
Author

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

@rafaelmaeuer
Copy link

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.

@serpino
Copy link

serpino commented May 29, 2018

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?

@RohitMane
Copy link
Author

@compulim
Copy link
Contributor

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.

@serpino
Copy link

serpino commented Jun 14, 2018

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

@compulim compulim changed the title Open url in same Tab of Browser, Its opening in new tab Open URL in same tab and not new window Jun 18, 2018
@Snekha-Shivakumar
Copy link

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

@serpino
Copy link

serpino commented Aug 28, 2018

@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

@corinagum
Copy link
Contributor

Related to #368, please refer to that issue for tracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants