boot

Initialize for the SDK.
The Channel button appears, and features like the marketing pop-up are ready to use.

For more details, see boot.

ChannelIO('boot', bootOption: object, callback?: Function)
parametertypedescription
bootOptionobjectA boot option to initialize the SDK.
callback(optional) FunctionCallback function executed after boot.
If boot fails, the callback receives an error object as the first argument and null as the second argument.
If boot succeeds, the callback receives null as the first argument and a user object as the second argument.
ChannelIO('boot', {
  pluginKey: 'YOUR_PLUGIN_KEY'
}, function onBoot(error, user) {
  if (error) {
    console.error(error);
  } else {
    console.log('boot success', user);
  }
});

shutdown

Stops all SDK operations and initializes internal data.

ChannelIO('shutdown');

showMessenger

Shows the messenger.

ChannelIO('showMessenger');

hideMessenger

Hides the messenger.

ChannelIO('hideMessenger');

openChat

Opens a chat.

  • If chatId is undefined, a new chat is opened. If the message argument is provided, it appears in the input field. If the support bot is active, it will be triggered.
  • If a chat corresponding to chatId exists, it is opened and the message argument is ignored. If the chat does not exist, an error page is displayed.
behaviorchatIdmessagenote
Open a new chat.undefinedundefinedIf the support bot is active, it will be triggered.
Open a new chat with a message.undefinedstringIf the support bot is active, it will be triggered.
The message appears in the input field after the support bot's operation.
Open a specific chat.stringundefinedIf the chat does not exist, an error page is displayed.
ChannelIO('openChat', chatId?: string, message?: string)
parametertypedescription
chatId(optional) stringThe chat ID.
message(optional) stringThe message to be inputted in the input field when a new chat opens.
// Opens a new chat.
ChannelIO('openChat');

// Opens a new chat with 'Text here' in the message field. 
// If the support bot is active, it's triggered before the message appears.
ChannelIO('openChat', undefined, 'Text here');

// Opens a chat with ID '123' or displays an error page if it doesn't exist.
ChannelIO('openChat', '123');

openSupportBot

Opens a chat and initiates a specific support bot.

  • If a support bot with the provided supportBotId exists, it will be triggered. If supportBotId is not provided or invalid, an error page is displayed.
  • If a message argument is provided, it will be inputted in the chat field after the support bot's operation completes.
behaviorsupportBotIdmessagenote
Trigger a specific support botstringundefinedDisplays an error page if supportBotId is invalid.
Trigger a specific support bot and input a message after completionstringstringDisplays an error page if supportBotId is invalid.
ChannelIO('openSupportBot', supportBotId: string, message?: string)
parametertypedescription
supportBotIdstringThe ID of the support bot.
message(optional) stringThe message to be inputted in the input field after the support bot's operation.
// Triggers the support bot with ID '123'. Displays an error if it doesn't exist.
ChannelIO('openSupportBot', '123');

// Triggers the support bot with ID '123' and inputs 'Text here' after completion. 
// Displays an error if the bot doesn't exist.
ChannelIO('openSupportBot', '123', 'Text here');

track

Tracks an event.

  • If you track a new event that has not been created before, it will be created.
  • It may take a few minutes to a few hours for the event to be visible at the desk.
ChannelIO('track', eventName: string, eventProperty?: object);
parametertypedescription
eventNamestringThe name of the event. A maximum of 30 characters is allowed.
eventProperty(optional) objectThe property of the event.
// Tracks an event named 'OrderRequest'.
ChannelIO('track', 'OrderRequest');

// Tracks an event named 'Order' with additional properties.
ChannelIO('track', 'Order', {
  "price": 100,
  "currency": 'USD'
});

onShowMessenger

Registers a callback that is invoked when the messenger is shown.

ChannelIO('onShowMessenger', callback: Function);
parametertypedescription
callbackFunctionCallback function invoked when the messenger is shown.
ChannelIO('onShowMessenger', function onShowMessenger() {
	console.log('Messenger is shown.');
});

onHideMessenger

Registers a callback that is invoked when the messenger is hidden.

ChannelIO('onHideMessenger', callback: Function);
parametertypedescription
callbackFunctionCallback function invoked when the messenger is hidden.
ChannelIO('onHideMessenger', function onHideMessenger() {
	console.log('Messenger is hidden.');
});

onBadgeChanged

Registers a callback that is invoked when there is a change in the count of messages that the user has not yet read.

ChannelIO('onBadgeChanged', callback: Function);
parametertypedescription
callbackFunctionCallback function invoked when there is a change in the count of messages that the user has not yet read.
The callback receives two arguments: unread (the total number of unread notifications, displayed as a red dot on the channel button) and alert (the number of important unread notifications, displayed as a number on the channel button).
ChannelIO('onBadgeChanged', function onBadgeChanged(unread, alert) {
	console.log(`Unread count: ${unread}, Alert count: ${alert}.`);
});

onChatCreated

Registers a callback that is invoked when a chat is created.

ChannelIO('onChatCreated', callback: Function);
parametertypedescription
callbackFunctionCallback function invoked when a new chat is created.
ChannelIO('onChatCreated', function onChatCreated() {
	console.log('New Chat is created.');
});

onFollowUpChanged

Registers a callback that is invoked when there are changes to the user's profile.

ChannelIO('onFollowUpChanged', callback: Function);
parametertypedescription
callbackFunctionCallback function invoked when the user's profile is updated.
The callback receives the updated profile object as an argument.

The profile object includes the following fields.

속성타입설명
name(optional) string | nullThe name of a user.
email(optional) string | nullThe email of a user.
mobileNumber(optional) string | nullThe mobile number of a user. It follows E.164 format.
ChannelIO('onFollowUpChanged', function onFollowUpChanged(profile) {
	console.log('User changed profile', profile);
});

onUrlClicked

Registers a callback that is invoked when the user clicks a link. This includes following links.

  • Link button or Link text in marketing pop-ups
  • Link button or Link text sent by managers in chat
ChannelIO('onUrlClicked', callback: Function);
parametertypedescription
callbackFunctionCallback function invoked when a link is clicked.
It receives the URL of the clicked link as an argument.
ChannelIO('onUrlClicked', function onUrlClicked(url) {
  console.log(`User clicked URL: ${url}`);
});

clearCallbacks

Clears all callbacks registered by following APIs.

ChannelIO('clearCallbacks');

updateUser

Update a user’s information.

ChannelIO('updateUser', userObject: object, callback?: Function);
parametertypedescription
userObjectobjectAn object containing the user’s information to be updated.
callback(optional) FunctionCallback function invoked after the update.
If the update fails, the callback receives an error object as the first argument and null as the second argument.
If the update succeeds, the callback receives null as the first argument and an updated user object at the second argument.

You can set the following fields to update a user’s information.

fieldtypedescription
language(optional) stringSets the user’s language. UI text changes to the specified language if language is ‘ko’ or ‘ja’. Otherwise, UI text defaults to English.
profile(optional) object | nullSets the user’s profile. Passing null resets the entire profile. To reset a specific field in the profile object, pass null for that field. Empty objects are not allowed, and field names should follow Camel Case. For mobileNumber, follow e.164 format.
profileOnce(optional) objectSets the user’s profile with fields that have no existing values.
tags(optional) array | nullSets the user’s tags. A maximum of 10 tags are allowed. Passing null resets all tags. Empty arrays are not allowed.
unsubscribeEmail(optional) booleanSets whether the user is subscribed to marketing emails. Subscription is terminated if set to true.
unsubscribeTexting(optional) booleanSets whether the user is subscribed to marketing SMS. Subscription is terminated if set to true.
const userObject = {
  language: 'ko',
  tags: ['a', 'b'],
  profile: {
    email: '[email protected]',
    mobileNumber: '+821012345678',
    name: 'test name',
  },
  profileOnce: {
    customerType: 'vip',
    registeredAt: '2022-11-22'
  },
  unsubscribeEmail: false,
  unsubscribeTexting: true
};

ChannelIO('updateUser', userObject, function onUpdateUser(error, user) {
  if (error) {
    console.error(error);
  } else {
    console.log('updateUser success', user);
  }
});

addTags

Adds a user’s tags.

ChannelIO('addTags', tags: array, callback?: Function)
parametertypedescription
tagsstring[]An array of tags to add. A maximum of 10 tags is allowed. Tags are always in lowercase.
callback(optional) FunctionCallback function invoked after adding tags. If the addition fails, the callback receives an error object as the first argument and null as the second argument. If the addition succeeds, the callback receives null as the first argument and an updated user object as the second argument.
ChannelIO('addTags', ['tag1', 'tag2'], function onAddTags(error, user) {
  if (error) {
    console.error(error);
  } else {
    console.log('addTags success', user);
  }
});

removeTags

Removes a user’s tags.

ChannelIO('removeTags', tags: array, callback?: Function)
parametertypedescription
tagsstring[]An array of tags to remove. If the corresponding tag does not exist, it will be ignored. Passing null or an empty array is not allowed.
callback(optional) FunctionCallback function invoked after removing tags. If the removal fails, the callback receives an error object as the first argument and null as the second argument. If the removal succeeds, the callback receives null as the first argument and an updated user object as the second argument.
ChannelIO('removeTags', ['tag1', 'tag2'], function onRemoveTags(error, user) {
  if (error) {
    console.error(error);
  } else {
    console.log('removeTags success', user);
  }
});

setPage

Set the page.
Page can be used instead of canonical URL.

🚧

Don’t pass null or undefined to page.

To reset the page, use resetPage.

ChannelIO('setPage', page: string)
parametertypedescription
pagestringThe value of the page to set.
ChannelIO('setPage', 'https://example.com/product');

resetPage

Reset the page value set by setPage.
When resetPage is used, the canonical URL will be used as the page value.

ChannelIO('resetPage');

showChannelButton

Show the channel button.

🚧

After boot, channel button shows without showChannelButton.

Manual execution of showChannelButton is only necessary if you have set hideChannelButtonOnBoot to true or have called hideChannelButton.

ChannelIO('showChannelButton');

hideChannelButton

Hides the channel button.

ChannelIO('hideChannelButton');

setAppearance

Set the appearance of the theme.

  • ‘light’: Uses the light theme.
  • ‘dark’: Uses the dark theme.
  • ‘system’: Follows the system theme.
  • null: Follows the theme setting from the desk.
ChannelIO('setAppearance', appearance: ‘light’ | ‘dark’ | ‘system’ | null)
parametertypedescription
appearance‘light’ | ‘dark’ | ‘system’ | nullThe appearance setting for the theme.
ChannelIO('setAppearance', 'dark');