Enjo Webchat SDK Documentation

16min

API reference

The Enjo Webchat SDK enables developers to seamlessly integrate a chatbot widget into their websites, allowing for dynamic interaction with users. This documentation outlines the key methods available in the SDK, providing clear descriptions and usage examples to help you effectively implement and utilize the SDK's features.

Getting Started

Installation:

Enjo Webchat can be installed either via a script tag in your HTML or programmatically using JavaScript.

To integrate the Enjo Webchat into your HTML file (e.g., index.html), follow these steps. Replace YOUR_WEBCHAT_ID with the actual Webchat ID provided by Enjo, and update the src attribute with the correct Enjo SDK URL.

JS


To dynamically load the Enjo Webchat script into your application, you can use JavaScript to add the script tag to your HTML at runtime. Here's how you can do it:

JS


To use the Enjo Webchat SDK, ensure you include the SDK in your web application and initialize it properly. Use the $enjo object to access SDK methods.

API Reference

1. Enjo Update User 

Description : 

This method allows you to dynamically update user attributes (like name, email, or other custom data) for a more personalized chat experience.

Parameters:

userObj (Object): The object containing user data such as name, email, signature, or other attributes.

If the userObj contains a signature and email, the Enjo SDK automatically verifies the user's email using the provided signature.

Example:

JS




2. Enjo Hide

Description

This method is used to programmatically hide the chat widget from view on your site:It is typically employed when you need to control the visibility of the chat widget based on specific conditions or user interactions within your application.

Example:

JS


3. Enjo show

Description 

This method is used to display the chat widget on the page. It is typically used when you want to make the widget visible to users, allowing them to interact with it as needed. This can be triggered based on user actions or specific conditions in your application.

Example:

JS


4. Enjo Show new message

Description 

This method is used to pre-populate and display a new message in the chat widget:It is typically employed to show a pre-written message to the user when they open the chat, enhancing user experience by providing immediate context or guidance.

Parameters:

  • content (String): The message content to be shown in the chat window.

Example:

JS


5. Enjo onHide

Description 

This method is used to register a callback function that will be executed whenever the chat widget is hidden. It allows you to implement custom actions or logic when the chat widget is closed, such as tracking user behavior or updating the interface accordingly.

Parameters:

  • callbackFn (Function): The function to be executed when the chat widget is hidden.

Example:

JS




6. Enjo onShow

Description 

This method is used to register a callback function that will be executed whenever the chat widget is shown. This is particularly useful for initiating actions or animations when the widget becomes visible, enhancing user interaction and engagement.

Parameters:

callbackFn (Function): The function to be executed when the chat widget is shown.

Example:

JS




7. Enjo onUserEmailSupplied 

Description

This method is used to register a callback function that is triggered when the user provides their email within the chat widget. This is useful for capturing the user's email for follow-ups, marketing, or other custom actions within your application.

Parameters:

  • callbackFn (Function): The function that handles the supplied email data.

Example:

JS


8. Enjo StartChat

Description

This method is used to immediately open the chat widget and send an initial message to start the conversation. This is particularly useful when you want to programmatically initiate a chat session with a pre-defined message, guiding the user and enhancing engagement from the outset.

Example :

JS


This will open the chat widget and display "Hi there! How can I assist you?" as the first message to the user.