API
not available at SDK
Huggy.showButton()Huggy.showButton();
Shows the button of the Huggy chat if it is hidden.
✔️ Here is an example of the application of this method.
not available at SDK
Huggy.hideButton()Huggy.hideButton();
This method is responsible for hiding the button of Huggy chat on the page.
✔️ Here is an example of the application of this method.
not available at SDK
Huggy.showChats()Huggy.showChats();
Shows the list of chats on Huggy chat if they are hidden.
not available at SDK
Huggy.hideChats()Huggy.hideChats();
Hides the list of chats' history and redirects for the last conversation of the user. The redirected chat is not the most recently one, but, the one that occurred the last interaction.
not available at SDK
Huggy.openBox()Huggy.openBox();
Opens the Huggy chat window if it is closed.
✔️ Here is an example of the application of this method.
not available at SDK
Huggy.closeBox()Huggy.closeBox();
Closes the window of the Huggy chat.
not available at SDK
Huggy.openButtons()Huggy.openButtons();
Creates and show the list of registered channels for calls.
✔️ Channels Telegram, Whatsapp, Email, Messenger.
not available at SDK
Huggy.openChatByID(id)Huggy.openChatByID(5);
Opens the chat of determined ID on the Huggy chat. This chat must be on the list of chats of the current user.
not available at SDK
Huggy.openEmail()Huggy.openEmail();
Opens the attendance window to the channel email.
not available at SDK
Huggy.openKnowledgeBase()Huggy.openKnowledgeBase();
Opens the base of knowledge registered on the settings of the Huggy chat (In case that it is configure).
not available at SDK
Huggy.openMessenger()Huggy.openMessenger();
Opens a attendance using the channel messenger by redirecting to the messenger's page.
not available at SDK
Huggy.openPhone()Huggy.openPhone();
Opens the window to insert the datas of phone for schedule a call.
not available at SDK
Huggy.openTelegram()Huggy.openTelegram();
Opens a attendance using the channel Telegram, redirecting to the Telegram's Web page.
not available at SDK
Huggy.openWhatsapp()Huggy.openWhatsapp();
Opens a attendance using the channel Whatsapp, redirecting to the Whatsapp's Web.
not available at SDK
Huggy.openInstagram()Huggy.openInstagram();
Opens an attendance using the Instagram channel, redirecting to the Instagram Web page.
Huggy.recreateAttendance()
Huggy.recreateAttendance();
Creates a new chat.
not available at SDK
Huggy.removeChats(id)Huggy.removeChats(2);
Removes of the list of chats a determined chat by its ID.
Huggy.sendMessage(Hello)
Huggy.sendMessage('Hello Charles!');
Sends a message on chat.
Huggy.setCustomerPhoto(url)
⚠️ The url passed by parameter must have the image file extension.
Huggy.setCustomerPhoto('https://c.pzw.io/img/avatar-user-boy.jpg');
Changes the customer's profile photo on the Huggy Chat.
Huggy.setData()
Huggy.setData(name, email, IDD, phone);
Huggy.setData('John Doe', 'john@email.com', '+1', 11988888888);
The Huggy.setData({})
function updates automatically the contact data on widget and on the Huggy panel. It is important to emphasize that for the definition of the custom fields, you should use the Token (automatically generated when a custom field is registered) as key of the object ‘custom_fields’ followed by the desired value. If you pass a nonexistent or invalid Token, it will be ignored.
Huggy.setData({
customer: {
name: 'John Doe',
mobile: '5511988888888',
email: 'johnl@company.com',
custom_fields: {
passport: '00000000000',
favorite_color: 'pink'
}
},
variables: [
{
key: 'profile',
value: 'Admin'
}
]
});
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Note: On your system, when the createChat event is triggered for the Huggy system, the variables must be passed as the initial chat context. The setData only works with the created chat.
Huggy.setEmail(email)
Huggy.setEmail('charles@test.com');
Changes the customer's email on the Huggy Chat.
Huggy.setName(name)
Huggy.setName('Charles');
Changes the customer name on the Huggy chat.
Huggy.setPhone(IDD, phone)
Huggy.setPhone("+1", "75999999999";
Changes the customer phone on the Huggy chat.
not available at SDK
Huggy.showTrigger(id)Huggy.showTrigger(3)
Shows certain trigger, using its ID.
✔️ Here is an example of the application of this method.
not available at SDK
Huggy.startTrigger(id, position, message)Huggy.startTrigger(3, 0, 'Initialize the Trigger');
Nota: The string being passed as a parameter has settings on the panel. If passed in the method, it overrides the configured value. Only the first parameter is required, the others are optional.
Runs the action of the trigger button, on this method only the ID is required. The ID is the trigger's ID, the position is the button position inside the trigger and in this case, as there is only a button, it is in a default position, this position cannot be changed, and the name in quotes is the name that will be displayed inside the button.
✔️ Here is an example of the application of this method.
Huggy.startTrigger(2, 0, 'Open the video');
Huggy.subscribe(topic, call)
The user subscribes to listen to the events of the topics { HuggyChatTopicsSubscribe } and runs a function passed by parameter, as shown in the example:
Huggy.subscribe('channel-open:whatsapp', function() {
alert('whatsapp channel opened');
});
2
3
✔️ Here is an example of the application of this method.
There is a specific topic (chat:created
) that emits a data object with the following properties:
{
authHash: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUxxxxxxxxxx",
chatID: 99999999,
customerSiteID: 999999999,
department: null,
hash: "f82768b90a3bdc6868b5xxxxxxxx",
last_notification: null,
message: {customer: {…}, agent: false, lastAgent: {…}, chatOpened: false, subject: null, …},
presence: "GmcjuRCzyimW%2B3qBjzWyXwDJwaV6xxxxxxxxxxx",
server: "https://ct.huggy.io",
smartTriggerID: null,
text: "Oi",
token: "5fec1013617ad07c104f84xxxxxxxxxxx",
whatsapp: null
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
To get this data you can runs a function as the following example:
Huggy.subscribe('chat:created', function(data) {
console.log('This is the chat Id: ', data.chatID);
});
2
3
Huggy.destroy()
Function that remove Huggy Chat instance of the page. To init again, Huggy.init function must be called. After destroy, the only function available is Huggy.init.
Huggy.destroy();