Integrations

Enjo Webchat SDK

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 \<script id="enjocopilot" webchatid="your webchat id" src="https //enjo sdk ai/webchat/js/w\ js" defer> \</script> 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 const script = document createelement("script"); script id = "enjocopilot"; script setattribute("webchatid", "your webchat id"); script src = "https //eno sdk ai/webchat/js/w\ js"; script defer = true; script onload = () => { console info("script loaded successfully!") }; script onerror = () => { console error("error loading the script!") }; document body appendchild(script); 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 $enjo("updateuser", { name "merry jane", email "merry jane\@example com", signature "abc123" } ); 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 $enjo("hide"); 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 $enjo("show"); 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 $enjo("shownewmessage", "hello! how can i assist you today?"); 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 $enjo("onhide", function() { console log("chat widget has been hidden "); }); 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 $enjo("onshow", function() { console log("chat widget is now visible "); }); 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 $enjo("onuseremailsupplied", function(email) { console log("user's email " + email); }); 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 $enjo("startchat", initialmessage) initialmessage (string) the message content that will be sent as the first message in the chat $enjo("startchat", "how can increase my credit card limit?"); this will open the chat widget and display "hi there! how can i assist you?" as the first message to the user