Freeday widget in ServiceNow
This document explains how to display the Freeday chat inside your ServiceNow
environment. Replace YOUR_CHANNEL_ID with the value provided by your Freeday
representative.
Prerequisites
- Administrator rights in your ServiceNow environment.
Create a ServiceNow widget
To display the Freeday chat, create a custom widget within ServiceNow. ServiceNow's documentation provides detailed instructions on how to create one.
The Freeday widget is injected as a script on your page. In the widget's
Client script
section, include the code below. Create a
single option
named channelid so you can specify different Channel IDs — for example, for a
production or an acceptance environment.
api.controller = function ($scope, $http) {
var c = this;
(async function () {
try {
const channelId = c.options.channelid;
if (!channelId) {
console.error('Channel ID is missing in widget options');
return;
}
const response = await fetch('https://api.freeday.ai/webchat/v1/widget/' + channelId);
const freedayConfiguration = await response.json();
const script = document.createElement('script');
script.src = freedayConfiguration.cdnUrlES5;
script.onload = function () {
if (window.FreedayWidget) {
window.FreedayWidget.bootstrap(freedayConfiguration);
} else {
console.error('freedayWidget not found');
}
};
document.head.appendChild(script);
} catch (error) {
console.error('Error loading Freeday widget:', error);
}
})();
};
Once the widget is created, you can include it on any page within the ServiceNow portal.