What are SDK Events? How to use these SDK events?
- Getting Started
- Bot Building
- Smart Agent Chat
- Conversation Design
-
Developer Guides
Code Step Integration Static Step Integration Shopify Integration SETU Integration Exotel Integration CIBIL integration Freshdesk KMS Integration PayU Integration Zendesk Guide Integration Twilio Integration Razorpay Integration LeadSquared Integration USU(Unymira) Integration Helo(VivaConnect) Integration Salesforce KMS Integration Stripe Integration PayPal Integration CleverTap Integration Fynd Integration HubSpot Integration Magento Integration WooCommerce Integration Microsoft Dynamics 365 Integration
- Deployment
- External Agent Tool Setup
- Analytics & Reporting
- Notifications
- Commerce Plus
- Troubleshooting Guides
- Release Notes
Table of Contents
You can deploy Haptik's bot either with the Haptik UI or as an API. Haptik offers its own UI in the form of an SDK.
Now users can take numerous actions on this UI (SDK). They can click on a certain button, they can hover over an image, etc., the list is endless. These actions taken on the SDK are termed as Events. You can now find out these events, in other words, listen to these events and use them if required on your website.
Why listen to SDK Events?
You can listen to SDK Events, for two main use cases.
- You want to track SDK events on your Analytics Tool: By listening to SDK events, you will be notified every time a user performs any action on the SDK. For example, if the user hovered on the Let’s Chat icon, or clicked on the icon to open the SDK, or maybe typed and sent a message through the composer. You can now track these events by dumping them straight into any Analytics Tools like Google Analytics, Mixpanel, etc. that you have integrated on your parent page.
- You want to change things on your website's parent page in response to what happens on the SDK: In a case where a user triggers a flow to see “ROI-Calculator” within the bot and you happen to have an ROI calculator on the website as well, you can now listen to the response the user gets from the bot (which will confirm that the user was looking for ROI-Calculator), and then based on this information showcase the ROI-Calculator on your webpage itself.
How do we subscribe to or listen to these Events?
You can use the HaptikInitSettings property sdkEvents to subscribe to the SDK’s events.
window.haptikInitSettings = {
...
sdkEvents: event => {
console.log('📣 from SDK: ', JSON.stringify(event));
}
};
...
};
The event object received will contain all the properties that will help you define which event had occurred and what properties were set.
What are the different Events and their properties?
The following table lists all the events and their corresponding properties.
Event Name |
When is the Event fired |
Property Name |
Description |
Property Values |
HAPTIK_APP_LOADED |
Every time the SDK is loaded on the Business's website |
- |
- |
- |
HAPTIK_CHAT_BUTTON_HOVERED |
Every time the user hovers on the Let's Chat button |
- |
- |
- |
HAPTIK_APP_EXPANDED |
Every time SDK is opened |
source_element |
This is the element that was used to open the SDK |
Chat Button, Bot prompt, launch_message, show |
bot_prompt_text |
The text of the Bot prompt that was clicked |
<Actual text of the bot prompt> |
||
bot_prompt_type |
What type of Bot prompt was clicked |
<Text or Omnichannel> |
||
launch_message_text |
Text of the launch Message |
<Actual text of launch Message> |
||
is_app_opened_first_time |
Boolean value. It is true, if this is the first time the user is opening the app |
True or False |
||
HAPTIK_APP_MINIMIZED |
Every time the SDK close icon was clicked |
- |
- |
- |
HAPTIK_FREEFORM_MESSAGE_SENT |
Every time user sends a freeform message through the composer |
message |
The actual message user sent |
<Actual text of sent message> |
HAPTIK_TASK_ITEM_CLICKED |
Every time user clicks on a Taskbox item |
item_id |
The ID of the item that was clicked |
<ID> |
item_title |
The actual title of the item |
<actual title of the task> |
||
HAPTIK_MENU_EXPANDED |
Every time user opens or expands the Task box |
- |
- |
- |
HAPTIK_MENU_MINIMIZED |
Every time user closes or minimizes the Task box |
- |
- |
- |
HAPTIK_BOT_PROMPT_SHOWN |
Every time a Bot prompt is shown on the screen |
id |
ID of the bot prompt |
<ID> |
type |
Type of the prompt |
<Text or Omnichannel> |
||
text |
Main text of the prompt |
<Actual text of prompt> |
||
HAPTIK_BOT_PROMPT_DISMISSED |
Every time a Bot prompt is dismissed by the user |
id |
ID of the bot prompt |
<ID> |
type |
Type of the prompt |
<Text or Omnichannel> |
||
HAPTIK_BOT_PROMPT_CLICKED |
Every time user clicks on a Bot prompt |
id |
ID of the bot prompt |
<ID> |
type |
Type of the prompt |
<Text or Omnichannel> |
||
cta |
Whether cta was clicked, text was clicked, or the Let's Chat icon was clicked |
CTA, text, chat_button |
||
message |
The message of the cta |
<Actual text of cta> |
||
HAPTIK_MESSAGE_SENT |
Every time user sends a message |
type |
How was the message sent? |
Freeform, Task Item, Bot prompt, Voice |
is_first_message |
Is this the first message which the user sent |
True or False |
||
message |
The actual message user sent |
<Actual text of sent message> |
||
HAPTIK_MESSAGE_RECEIVED |
Every time the SDK receives a response from the bot |
is_message_by_agent |
Whether this message is received from the agent or not |
True or False |
HAPTIK_LANGUAGE_ICON_CLICKED |
Every time user clicks on the language-change icon |
- |
- |
- |
HAPTIK_LANGUAGE_SELECTED |
Every time user selects a new language |
from_language |
Language code of the selected language |
language code |
to_language |
Language code of the selected language |
language code |
||
HAPTIK_LANGUAGE_AUTO_CHANGED |
Every time Bot's language was changed from the backend. This will happen whenever language-detection detects that the user typed in a different language. Language-detection will then go ahead and automatically change the bot's language |
from_language |
Language code of the selected language |
language code |
to_language |
Language code of the selected language |
language code |
||
HAPTIK_MIC_TAPPED |
Every time user clicks on Mic icon |
- |
- |
- |
HAPTIK_MIC_CLOSED |
Every time user clicks on cancel mic |
- |
- |
- |
HAPTIK_WEBVIEW_SHOWN |
Every time a webview message is received from the bot |
link |
The target link of the webview |
<actual link> |
HAPTIK_WEBVIEW_OPENED |
Every time user clicks and opens a webview message |
link |
The target link of the webview |
<actual link> |
HAPTIK_WEBVIEW_DISMISSED |
Every time user closes an opened webview without submitting |
link |
The target link of the webview |
<actual link> |
HAPTIK_WEBVIEW_SUBMITTED |
Every time user submits the webview |
link |
The target link of the webview |
<actual link> |
HAPTIK_BUTTON_CLICKED |
Every time user clicks on a QR, Button or a Link |
type |
Whether the button is a QR, Button, Link |
QR, Action Button, Link |
value |
Text value of the button or the link |
<actual text> |
||
HAPTIK_AGENT_ENTERED |
Every time an agent enters the conversation |
agent |
Gives you agent details |
JSON object which has the following properties:
|
HAPTIK_AGENT_EXITED |
Every time an agent marks the chat as complete |
- |
- |
- |
HAPTIK_CHAT_USER_OFFLINE |
Every time the user loses their Internet Connection. | - | This event is fired if the user loses their Internet Connection. |
- |
HAPTIK_CHAT_USER_ONLINE |
Event is fired only for those users who were offline but are now back online. | - | This event is fired if the user was already offline and is now re-connected to the Internet. Thus, this event will not be fired if the Offline event was never fired. |
- |
How can we use these Events for analytics?
Clubbing different events together will help us form funnels.
For example,
`HAPTIK_APP_LOADED` → `HAPTIK_CHAT_BUTTON_HOVERED` → `HAPTIK_APP_EXPANDED` can form a funnel of:
- How many times the SDK was loaded and thus the Let’s Chat button was shown on the screen.
- Of that, how many times the Let’s Chat button was hovered on.
- Of that, how many times do users click on the Let’s Chat button to open the SDK.
Few more examples of similar funnels that can be built using events like:
- `HAPTIK_BOT_PROMPT_SHOWN` → `HAPTIK_BOT_PROMPT_DISMISSED` → `HAPTIK_BOT_PROMPT_CLICKED` can be used to create a Bot prompt usage funnel.
- `HAPTIK_LANGUAGE_ICON_CLICKED` → `HAPTIK_LANGUAGE_SELECTED` can be used to create funnels to see Language change funnels.
- `HAPTIK_MIC_TAPPED` → `HAPTIK_MIC_CLOSED` can show us how many times users clicked on the mic icon but canceled the voice message before it could be sent.