API

Huggy.showButton() not available at SDK

Huggy.showButton();
1

Shows the button of the Huggy chat if it is hidden.

Huggy.hideButton() not available at SDK

Huggy.hideButton();
1

This method is responsible for hiding the button of Huggy chat on the page.

Huggy.showChats() not available at SDK

Huggy.showChats();
1

Shows the list of chats on Huggy chat if they are hidden.

Huggy.hideChats() not available at SDK

Huggy.hideChats();
1

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.

Huggy.openBox() not available at SDK

Huggy.openBox();
1

Opens the Huggy chat window if it is closed.

Huggy.closeBox() not available at SDK

Huggy.closeBox();
1

Closes the window of the Huggy chat.

Huggy.openButtons() not available at SDK

Huggy.openButtons();
1

Creates and show the list of registered channels for calls.

✔️ Channels
Telegram, Whatsapp, Email, Messenger.

Huggy.openChatByID(id) not available at SDK

Huggy.openChatByID(5);
1

Opens the chat of determined ID on the Huggy chat. This chat must be on the list of chats of the current user.

Huggy.openEmail() not available at SDK

Huggy.openEmail();
1

Opens the attendance window to the channel email.

Huggy.openKnowledgeBase() not available at SDK

Huggy.openKnowledgeBase();
1

Opens the base of knowledge registered on the settings of the Huggy chat (In case that it is configure).

Huggy.openMessenger() not available at SDK

Huggy.openMessenger();
1

Opens a attendance using the channel messenger by redirecting to the messenger's page.

Huggy.openPhone() not available at SDK

Huggy.openPhone();
1

Opens the window to insert the datas of phone for schedule a call.

Huggy.openTelegram() not available at SDK

Huggy.openTelegram();
1

Opens a attendance using the channel Telegram, redirecting to the Telegram's Web page.

Huggy.openWhatsapp() not available at SDK

Huggy.openWhatsapp();
1

Opens a attendance using the channel Whatsapp, redirecting to the Whatsapp's Web.

Huggy.openInstagram() not available at SDK

Huggy.openInstagram();
1

Opens an attendance using the Instagram channel, redirecting to the Instagram Web page.

Huggy.recreateAttendance()

Huggy.recreateAttendance();
1

Creates a new chat.

Huggy.removeChats(id) not available at SDK

Huggy.removeChats(2);
1

Removes of the list of chats a determined chat by its ID.

Huggy.sendMessage(Hello)

Huggy.sendMessage('Hello Charles!');
1

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');
1

Changes the customer's profile photo on the Huggy Chat.

Huggy.setData()

Huggy.setData(name, email, IDD, phone);
1
Huggy.setData('John Doe', 'john@email.com', '+1', 11988888888);
1

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'
    }
  ]
});
1
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');
1

Changes the customer's email on the Huggy Chat.

Huggy.setName(name)

Huggy.setName('Charles');
1

Changes the customer name on the Huggy chat.

Huggy.setPhone(IDD, phone)

Huggy.setPhone("+1", "75999999999";
1

Changes the customer phone on the Huggy chat.

Huggy.showTrigger(id) not available at SDK

Huggy.showTrigger(3)
1

Shows certain trigger, using its ID.

Huggy.startTrigger(id, position, message) not available at SDK

Huggy.startTrigger(3, 0, 'Initialize the Trigger');
1

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.

Huggy.startTrigger(2, 0, 'Open the video');
1

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');
});
1
2
3

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
}
1
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);
});
1
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();
1

Types