let chatConfig = {};
function createChatConfig() {
var firstName = document.getElementById('firstName').value; var lastName = document.getElementById('lastName').value; var email = document.getElementById('email').value; var accountNumber = document.getElementById('accountNumber').value;
chatConfig = { // Web chat application URL "webchatAppUrl": "https://apps.mypurecloud.com/webchat",
// Web chat service URL "webchatServiceUrl": "https://realtime.mypurecloud.com:443",
// Numeric organization ID "orgId": 14970,
// Organization name "orgName": "associatedcreditunionoftexas",
// Requested agent language skill (Agent must have this language skill to receive chat) //"language": "English - Written",
// Requested agent skills (Agent must have these skills to receive chat) //"skills": ["Computers", "Printers"], // OR //"skills": [],
// Priority "priority": 0,
// Queue Name "queueName" : "ACUIS Service Chat",
// Target agent email (OPTIONAL) //"agentEmail": agentEmail,
// Log level "logLevel": "DEBUG",
// Locale code "locale": "en",
// Data that will be included with interaction "data": { "firstName": firstName, "lastName": lastName, "customerId": accountNumber, "customField1Label": 'Email', "customField1": email },
// Logo used at the top of the chat window "companyLogo": { "width": 200, "height": 174, "url": "https://cufginsurance.org/wp-content/uploads/2018/04/CUFG-Insurance-Logo-200.png" },
// Logo used within the chat window "companyLogoSmall": { "width": 25, "height": 22, "url": "https://cufginsurance.org/wp-content/uploads/2018/04/CUFG-Insurance-Logo-25.png" },
// Image used for agent "agentAvatar": { "width": 462, "height": 402, "url": "https://cufginsurance.org/wp-content/uploads/2018/04/CUFG-Insurance-Logo-462.png" },
// Text displayed with chat window is displayed "welcomeMessage": "Welcome to the Insurance Service Center, an Agent will be right with you please put in your policy number if you have one.",
// CSS class applied to the chat window "cssClass": "webchat-frame",
// Custom style applied to the chat window "css": { "width": "100%", "height": "100%" } // Other web chat configuration here // Set up times chat is not available // Removes 'purecloud-chat-available' class from chatNowElement // Chat is not available Saturday Sunday, and many holidays offlineSchedules: [{ day: 'Saturday,Sunday', city: 'America/Chicago' }. //Holiday Stuff { //Holiday Memorial day date: 28, month: 5, year: 2018, city: 'America/Chicago' }, { //Holiday Independence day date: 4, month: 7, year: 2018, city: 'America/Chicago' }, { //Holiday Labor day date: 3, month: 9, year: 2018, city: 'America/Chicago' }, { //Holiday Columbus day date: 8, month: 10, year: 2018, city: 'America/Chicago' }, { //Holiday Thanksgiving date: 22, month: 11, year: 2018, city: 'America/Chicago' }, { //Holiday Day After Thanksgiving date: 23, month: 11, year: 2018, city: 'America/Chicago' }, { //Holiday Christmas Eve date: 24, month: 12, year: 2018, city: 'America/Chicago' }, { //Holiday Christmas Eve date: 25, month: 12, year: 2018, city: 'America/Chicago' }],
// Set up times chat is available. // Adds 'purecloud-chat-available' class to chatNowElement when available // Chat is available Monday through Friday, 800 a.m. to 600 p.m., using the. onlineSchedules: [{ day: 'Monday-Friday', time: '0800-1800', city: 'America/Chicago' }],
// Element that will have 'purecloud-chat-available' class added to it when // intersection of online and not offline schedules chatNowElement: 'chatAvailableButton', }; }
function startEmbeddedChat() {
document.getElementById("chatForm").style.display = "none";
createChatConfig(); ININ.webchat.create(chatConfig, function(err, webchat) { if (err) { throw err; }
// Render to frame webchat.renderFrame({ containerEl: 'chatContainer' });
webchat.chatStarted = function () { //Code to run when the chat is started };
webchat.chatConnectedToAgent = function () { //Code to run when the chat is connected to an agent };
webchat.chatEnded = function () { //Code to run when chat ends. document.getElementById("chatForm").style.display = "block"; document.getElementById("chatContainer").style.display = "none"; };
}); }
function startPopupChat() { createChatConfig(); ININ.webchat.create(chatConfig, function(err, webchat) { if (err) { throw err; } // Render to popup webchat.renderPopup({ width: 400, height: 400, title: 'Chat', //set newTab to true if using screen share newTab: false }); }); }