Comment on page

Synchronize users data with Subiz API

API (application programming interface) is a set of clearly defined methods of communication between various software components. Subiz provides a Javascript API that synchronizes users data between the Subiz app and the website. You can update users information, retrieve users and clear users.
Important notes:
  • API snippets should be placed after the Subiz embed code in the website code page. No need to follow closely, just make sure the Subiz embed code is placed over the API snippets.
  • To use Javascript API, only programmers can install according to instructions. If your business does not have its own programmer, hire a frelance programmer to help them.

1. User attributes

The four default user attributes set up on Subiz are about basic user information, such as: Full name, Email address, Phone number, Address.
Subiz lets you create and generate new attributes about your users, based on criteria that is specific to your business. You can user this data as qualification data to qualify leads and boost sales. You can also use this data to filter and send targeted Automation messages.
Create new attribute on Subiz

2. API updates user attributes on Subiz

You can use the Javascript Subiz API to update automatically your default user attributes on Subiz or update your own custom user attributes.
Here is an example of Javascript API to update full-name attribute:
subiz('updateUserAttributes', [{ key: 'fullname', text : 'David’ }]);
Things must remember:
  • Key is attribute key
  • Data type: Text, Number, Boolean, List, Date Time. (See detailed notes)
Here are just some examples of what our JavaScript API lets you do:

2.1. Update a default attribute

Full name attribute
Phone number attribute
Email address attribute
<script> subiz('updateUserAttributes', [{ key: 'fullname', text : 'David’ }]); </script>
<script> subiz('updateUserAttributes', [{ key: ’phones’, text : '09123456789', '0987654321' }]); </script>
<script> subiz('updateUserAttributes', [{ key: 'emails’, text :'exa[email protected], [email protected]' }]); </script>

2.2. Update simultaneously multiple default attributes

Update simultaneously multiple default attributes
subiz('updateUserAttributes', [{ key:'fullname', text : 'David' },{ key:'phones', text : '09123456789' } ]);

2.3. Update new custom attribute(s)

Below are two examples of such custom attributes as Language and Customer:
Language attribue
Customer attribute
<script> subiz('updateUserAttributes', [{ key:'ngon_ngu', list : [‘Vietnamese’, ‘English’] } ]); </script>
<script> subiz('updateUserAttributes', [{ key:'khach_hang', boolean : true }]); </script>

3. API delete all user data

API allows you to delete user data on Subiz. The deleted data includes all information on the visitor's browser in Subiz. Therefore, when you deleted, you can't see this user anymore.

4. API synchronizes user data from Subiz to website

API allows you to synchronizes user data from Subiz to website.
API synchronizes user data from Subiz to website
<script> subiz('getUserAttributes', (attributes) => {console.log('user attributes', attributes)}); </script>

5. Assign language for Subiz Widget

The API allows the website to assign the display language of Subiz Widget. After that, you can decide which page displays Vietnamese or English. This is an example of Javascript API to assign English for Subiz widget, inside "en" is the language code:
subiz('setLanguage', 'en');
Language code is the representation of names of languages according to ISO 639-1 standard (two characters) and the language that Subiz currently support. You could refer the list of languages that Subiz supported.

6. Expand / Shrink Subiz Widget

The API allows you to expand Subiz Widget. For example, you can create a button on the website so that when visitors click on that button, the Subiz widget will expand.
  • The example bellow will show you API expand Subiz widget via Javascript function.
<script type="text/javascript">
  • API attach a link to order to Expand Subiz widget.
<a href="#nogo" onclick="subiz('expandWidget')">Text of </a>
  • API Shrink Subiz widget.
<script type="text/javascript">
  • API attach the link to shrink Subiz widget.
<a href="#nogo" onclick="subiz('shrinkWidget')">text của </a>

7. Customize CSS

The API allows you use a CSS code to Customize the Subiz widget base on your idea. The function helps you to customize Subiz widget for each website with its own style.
<script type="text/javascript">
window.subiz('changeCss', '.widget_mini .widget_body {height: 750px !important; max-height: 800px !important;}')
You could also refer to instruction how to custom CSS Subiz chat widget.

8. Customize Widget Position

You can customize widget position by utilizing API code as follow:
subiz('setPosition', 'left') . value left or right

9. Customize Widget Type

Customizing widget type: standard or full height by using this API code:
subiz('setWindowMode', 'full') . value full or mini

10. Customize Subiz tittle on header

You can change the instruction on header by using by this API code:
subiz('setLanguageData', {}) . VD subiz('setLanguageData', {message_input_help: "Type", joined_the_conversation: "joined"})

11. API Subscribe Push Notification

The API allows you to actively ask the user if they were agree to receive a notification when their Subiz widget has a new message. You can Link chat widget to a text or an image on website or link to increase the number of people who agree to receive notifications.
  • API subscribe to receive notifications.
<script type="text/javascript">
  • API to unsubscribe to receive notifications.
<script type="text/javascript">
  • API to check if the user has agreed to receive notifications?
<script type="text/javascript">
subiz('checkPushNotification', function(status) {
Do you need help? Just click on and chat with us!