Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Go to Haptik Website
  • Contact Us
  • Home
  • Deployment
  • Web SDK

What are the SDK customization methods available?

Written by Medha Anand

Updated on July 6th, 2023

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Getting Started
    Build Deploy Analyse Manage Account Bot Deactivation
  • Bot Building
    Essentials Smart Skills Steps User Messages Bot Responses Entities Connections Customisations User feedback collection Testing Whatsapp Bots NLU Bot Maintenance
  • Smart Agent Chat
    Set up Admin Settings MyChats Section (Agent Inbox) Live Traffic Section Teams Section Archives Section Analytics Plans on Smart Agent Chat
  • Conversation Design
    Design Basics Design Guides Designing for Platforms Designing WhatsApp Bots
  • 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
    Web SDK WhatsApp Facebook Instagram Sunshine Conversation LINE Google Business Messages Telegram MS Teams Bot as an API iOS SDK Android SDK
  • External Agent Tool Setup
    Zendesk Chat Salesforce Service Cloud Freshchat Zoho NICE CXOne Gorgias
  • Analytics & Reporting
    Intelligent Analytics
  • Notifications
    SMS Notifications Success Measurement
  • Commerce Plus
    Catalog Integration Bot Building Guide Channel Deployments Unified ML Pipeline Documentation
  • Troubleshooting Guides
    Error Messages FAQs
  • Release Notes
+ More

Table of Contents

Client Accessible SDK Event Listener Glossary init(initSettings) destroy() show() hide() openLanguagePicker() signup(authOptions, callback) logout(callback) renewSignupToken(newToken, callback) prompt(title, message) launchTask(taskId, callback) launchMessage(message, callback, hidden, hideChatWindow, skipMessage, hideWelcomeMessage) changeLanguage(languageCode, callback) updateUserData(userData, callback)

Client Accessible SDK

When the SDK loads, it exposes a Javascript SDK. This Javascript SDK can then be used to programmatically control some of the behavior of the SDK.

Event Listener

In order for these methods to be accessible, the SDK needs to load first. The SDK emits a custom event to notify any/all subscribers that it has loaded.

 document.addEventListener('haptik_sdk', function() {
 // HaptikSDK is available now
 HaptikSDK.init(...);
 });

Note: Using other listeners like window.onload or document.onload will lead to inconsistent behavior as the Haptik SDK might not have been initialized yet.

Glossary

  • init(initSettings)
  • destroy()
  • show()
  • hide()
  • openLanguagePicker()
  • signup(authOptions, callback)
  • logout(callback)
  • renewSignupToken(newToken, callback)
  • prompt(title, message)
  • launchTask(taskId, callback)
  • launchMessage(message, callback, hidden, hideChatWindow, skipMessage, hideWelcomeMessage)
  • changeLanguage(languageCode, callback)
  • syncCustomData(userData, callback)

init(initSettings)

Initialize the SDK and load a particular bot

Params:

  • initSettings <Object>The client settings comprising of
    • client-id: <String>: Client Identifier (Provided by Haptik)
    • base-url: <String>: Backend Identifier (Provided by Haptik)
    • business-id: <Number>: Business Identifier (Provided by Haptik)
    • privacy-policy-url: <String>: URL to your Privacy Policy (Optional). This is useful if GDPR is enabled. If not provided users will be redirected to Haptik's privacy policy page.
    • initialize-language: <String> *: Code of language you want to open bot with. For eg en, hi. (Optional). We support ISO_639-1 language codes.

destroy()

When there are 2 SDKs (one for guest use and another for logged in user) adding destroy() will clear out all the information and context from the previous instance (guest bot) to load the second bot (logged in bot)

Params:

show()

Opens up the SDK main window. (The same as clicking on the let's chat icon)

Params:

hide()

Closes the SDK main window. (The same as clicking on the cross icon while the window is open)

Params:

openLanguagePicker()

Opens up a language picker. (The same as clicking on the language picker icon in the header)

Params:

signup(authOptions, callback)

Only applicable for custom signup bots. Use this function to make a custom call for passing sign-on information to the SDK. (Refer to the custom signup section for more information)

Params:

  • authOptions <Object>: The authorization information necessary to securely authenticate the user.
    • authId <String>: The authentication Id
  • callback <Function>The callback executes once the call completes. The callback function is executed with success boolean flag as a parameter indicating whether the call was completed or failed.

logout(callback)

This method logs out the currently logged in user and clears its data

Params:

  • callback <Function>The callback executes once the call completes.

renewSignupToken(newToken, callback)

Only applicable for custom signup bots. If the authToken sent above expires, use this function to send the updated token to our backend

Params:

  • newToken <String>The new token that needs to be synced with our backend
  • callback <Function>The callback executes once the call completes. The callback function is executed with success the boolean flag as a parameter indicating whether the call was completed or failed.

prompt(title, message)

Creates a bot prompt to catch the user's attention. However, we recommend using dynamic bot prompts configured through the Bot-Builder. See the Bot Prompts section for more details.

Params:

  • title <String>The text that's displayed on the bot prompt.
  • message <String>The message that's sent if the user taps on the bot prompt.

launchTask(taskId, callback)

Launches the SDK and automatically sends specified taskId as a user message (The same message that would be sent if the user tapped on that task)

Params:

  • taskId <Number>The task id is specified in the tasks section of the bot builder (business manager)
  • callback <Function>(optional)The callback executes once the call completes. The callback function is executed with success a boolean flag as a parameter indicating whether the call completed or failed.

launchMessage(message, callback, hidden, hideChatWindow, skipMessage, hideWelcomeMessage)

Launches the SDK and automatically sends a specific message as a user message. It can optionally be sent as a hidden user message

Params:

  • message <String>The message that is to be sent
  • callback <Function>(optional)The callback executes once the call completes. The callback function is executed with success boolean flag as a parameter indicating whether the call was completed or failed.
  • hidden <Boolean>Whether to send the message as a hidden user message. A hidden message is not visible to the user but can be seen by the agent or bot
  • hideChatWindow <Boolean>  If set to true, the chat window will not get opened on launching the message.
  • skipMessage <Boolean> If set to true, the SDK will not send a launch message if the last message is a reply to a previous launch message.
  • hideWelcomeMessage <Boolean>  If set to true, the Welcome Message will not be shown when the launch message is sent.

changeLanguage(languageCode, callback)

Only applicable to multi-language bots. Changes the current language of the SDK to the language codes specified. Note: This language code must be supported by the bot in order for it to work.

Params:

  • languageCode <String>The language code to switch to (Ex. en)
  • callback <Function>(optional)The callback executes once the language change completes.
Delete

Presently, we do not support changing the icon and the size of the change language button.

updateUserData(userData, callback)

Use this method to update the user details and custom data. Make sure to call this method only after signup. Only email, mobile_no, username, and custom_data, fields are allowed in the userData dictionary.

Examples:

const userData = {
  email: "test@email.com",
  mobile_no: "8989898989",
  username: "User Name",
  custom_data: {
    order_id: 12345,
    date: "01/01/2022"
  }
};


HaptikSDK.updateUserData(userData);

You can omit the fields which are not required to be updated.

const userData = {
  username: "User Name",
  custom_data: {
    order_id: 12345,
    date: "01/01/2022"
  }
};


HaptikSDK.updateUserData(userData);

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • How to deploy a bot on my website?
  • How to have a custom icon for my website bot?
  • How to set up a launch message on my website bot?

Platform

  • Conversation Studio
  • Smart Skills
  • Advanced NLU
  • Intelligent Analytics
  • Omnichannel
  • Smart Agent Chat
  • Enterprise Security
  • Integrations

Solutions

  • Conversational Commerce
  • Lead Generation
  • Customer Care
  • WhatsApp
  • Conversational IVR
  • Google Business Messages

Industries

  • Retail/ E-Commerce
  • Financial Services
  • Travel & Hospitality
  • Telecom

Knowledge

  • ROI Calculator
  • Reports & Research
  • Case Studies
  • Webinars
  • ISAT
  • Tech Blog
  • Business Blog
  • Resources
  • Haptik v/s Yellow
  • Haptik v/s Liveperson
  • Haptik v/s IBM Watson
  • Haptik v/s Verloop
  • Conversations on AI

Company

  • Why Haptik
  • About Us
  • Careers
  • News & Media
  • Awards & Recognition
  • Contact Us
  • Partnerships
  • Investor Relations

Subscribe

Sign up to recieve the latest updates

Find us on

  • Twitter-footer
  • Linkedin-footer
  • YT-footer
  • Insta-footer
  • G2-footer
  • Facebook-footer

Knowledge Base Software powered by Helpjuice

Copyright © jio Haptik Technology Limited 2021 | Data Security & Privacy Policy | GDPR

North America | Asia Pacific | Africa | enterprise@haptik.ai

Definition by Author

0
0