Change Behavior of AI Chatbot Generated Hyperlinks

Howdy,

AI Chatbot-generated hyperlinks always open in a new tab. Questions:

  1. Is this the natural behavior of your AI Chatbot widget?
  2. Is there a way to override this? Meaning, I’d like same-site hyperlinks to open in the same tab, and all others (i.e., external links) to open in a new tab. Unfortunately, AI bot training did not help.

Thank you!

1 Like

Sure! Your request is with our devs now, and I’ll update you once the solution is ready :slightly_smiling_face:

1 Like

Hi there, @AeroConsultants :waving_hand:

Thank you for waiting!

We’ve added this code to the Custom JS field on the General tab of your widget’s settings:

const HOST_NAME = 'omniaaerospace.com';
document.addEventListener('click', (event) => {
	const link = event.target.closest(
		`.eapps-ai-chatbot-${WIDGET_ID}-custom-css-root a`
	);

	if (!link) {
		return;
	}

	event.preventDefault();
	if (link.href.includes(HOST_NAME)) {
		window.open(link.href, '_self');
	} else {
		window.open(link.href, '_blank');
	}
});

Please check it out and let me know if you like the result :slightly_smiling_face:

1 Like

Hey @Max,

Tested. It worked. Thank you!

Notes:

  1. For future reference, please do not modify our CSS or JS code directly in our widget. As you’ve done before, please post the code in your reply and I will enter/test it at my end. Main reason: The current CSS and JS Code fields are small and narrow. With all the code we have entered, things can get a bit confusing without a “Comment” for each code. A single stream of code can create a lot of downstream issues.

  2. As suggested before, Elfsight developers are providing many useful JS Codes that apply universally to all customers. Please add a “JS Codes” category to the Community Board as you’ve done for “CSS Codes” This will help your customers find useful JS Codes fast.

Cheerio!

1 Like

Got it, thanks!

We’ll think about introducing a separate category for the JS codes, and sorry for the confusion by adding the codes right away. We’ll just post them in the messages in the future :slightly_smiling_face:

1 Like

Thanks, @Max!

Everybody wins!

By the way, I truly admire and appreciate your dedication to the community and your customers.

Keep up the great job. I think you’re ready for a promotion! :grin:

Salud!

2 Likes

Many thanks for your kind words! That’s exactly what inspires us to always move forward :heart:

2 Likes