Skip to content

Instantly share code, notes, and snippets.

@jrstaatsiii
Created July 25, 2025 14:23
Show Gist options
  • Select an option

  • Save jrstaatsiii/84dccc65babfc67bf6e1acbc7a2a3ec7 to your computer and use it in GitHub Desktop.

Select an option

Save jrstaatsiii/84dccc65babfc67bf6e1acbc7a2a3ec7 to your computer and use it in GitHub Desktop.
<script>
function openChat() {
console.log(`Chat button clicked ${new Date().toLocaleString()}`);
// Use the official Five9 open method from the global namespace
try {
if (typeof window.FIVN !== "undefined" && window.FIVN.open) {
window.FIVN.open();
console.log("Chat opened via official FIVN.open() method");
} else {
console.error("Five9 FIVN global object or open method not available");
}
} catch (error) {
console.error("Error opening chat:", error);
}
}
// Initialize Five9 Chat Widget when page loads
window.addEventListener('load', function() {
if (typeof F9 !== "undefined" && F9.Chat && F9.Chat.Wrapper) {
F9.Chat.Wrapper.init({
cdn: 'prod',
useBusinessHours: false,
languages: {"enabled":false,"backgroundColor":"#ff9d00"},
l10n: {"en":{"messenger":{"customText":{}},"systemMessages":{"transferredToParticipant":"The chat has been transferred to {name}.","transferredToGroup":"That chat has been transferred to group {group}."},"captureFields":[{"k":"campaign","l":"How can we help?","p":"Choose a campaign...","o":[{"v":"Chatbot","l":"File a claim"},{"v":"Agent","l":"Agent"},{"v":"New Customer","l":"New Customer"},{"v":"Policyholder","l":"Policyholder"},{"v":"Mortgage Company","l":"Mortgage Company"},{"v":"Other","l":"Other"}]},{"k":"name","l":"Name","p":"Enter your name..."},{"k":"email","l":"Email Address","p":"Enter your email..."}]}},
prepopulatedFields: [{"k":"Question","v":"N/A"}],
messenger: {"integrationId":"8065c37d-75ec-4acb-8b9c-7e91608be3bf","soundNotificationEnabled":true,"transcriptPrintingEnabled":false,"menuItems":{"imageUpload":true,"fileUpload":true,"shareLocation":true},"embedded":false,"setViewportScale":false,"browserStorage":"sessionStorage","hideWidgetAfterBusinessHours":false,"openLinkInSameTab":false,"scheduleCallback":{"isCallbackEnabled":false,"requestCallbackList":"","customConfirmationMessage":"We will call you as soon as we can at [PHONE]","web2CampaignAPIHost":""},"fixedHeader":false,"displayStyle":"button","customColors":{"brandColor":"ff9d00","conversationColor":"0056ff","actionColor":"4B5DFF"},"carouselType":"default"},
clearMessagesTimeout: 3
});
console.log("Five9 Chat Widget initialized successfully");
} else {
console.error("Five9 Chat library not loaded");
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment