JavaScript SDK

Developer API

A simple yet powerful JavaScript API that gives you full control over your chat widget behavior, styling, and integrations.

Easy Setup

Just add our snippet to your page. The API is automatically available once the script loads.

Full Control

Show, hide, and customize the chat widget. Prefill user info and add custom parameters.

Event Callbacks

React to chat events like open, close, and end with custom callback functions.

Getting Started

Ensure you have the Social Intents code snippet installed on your page. Once loaded, you can use any of the methods below via the SI_API object.

callback onSIApiReady()

This callback notifies your page when the Social Intents API has finished loading. Since scripts load asynchronously, wrap your initialization logic in this function.

JavaScript
function onSIApiReady() {
  // API is ready - initialize your logic
  SI_API.showTab();
}

Widget Control

method SI_API.showInvite(message)

Display the proactive chat invite with a custom message. Great for creating page-specific invite messages to increase conversions.

JavaScript
function onSIApiReady() {
  SI_API.showInvite('Questions about our products? I can help!');
}

method SI_API.showPopup() / SI_API.hidePopup()

Show or hide the chat window programmatically. Use these for custom display rules or to auto-close after a period of time.

JavaScript
// Show the chat window
SI_API.showPopup();

// Hide the chat window
SI_API.hidePopup();

method SI_API.showTab() / SI_API.hideTab()

Show or hide the chat tab button. Display it after a custom delay, on specific pages, or after certain user actions.

JavaScript
function onSIApiReady() {
  // Show tab after 5 seconds
  setTimeout(() => {
    SI_API.showTab();
  }, 5000);
}

User Data & Parameters

method SI_API.setChatInfo(name, email, phone, group, question)

Pre-populate visitor information. Perfect for member sites where you've already collected user data. Disable fields in your settings to prevent visitors from changing pre-filled values.

JavaScript
function onSIApiReady() {
  SI_API.setChatInfo(
    'John Doe',           // name
    'john@example.com',    // email
    '(123) 456-7890',      // phone
    'Sales',               // group/department
    'Question about pricing' // initial question
  );
}

method SI_API.addParams(params)

Add custom key-value parameters to each chat request. Send customer info, order numbers, page context, or any other data your agents need.

JavaScript
function onSIApiReady() {
  var params = [];
  params.push({ name: 'Member ID', value: 'abc123' });
  params.push({ name: 'Order Number', value: 'ORD-1000' });
  params.push({ name: 'Plan', value: 'Enterprise' });
  
  SI_API.addParams(params);
}

Event Callbacks

React to user interactions with the chat widget using these callback methods.

callback SI_API.onChatOpened

Triggered when the chat button is clicked and the chat window appears.

JavaScript
function onSIApiReady() {
  SI_API.onChatOpened = function() {
    // Track in analytics
    gtag('event', 'chat_opened');
  };
}

callback SI_API.onChatClosed

Triggered when the chat window is minimized.

JavaScript
function onSIApiReady() {
  SI_API.onChatClosed = function() {
    console.log('Chat minimized');
  };
}

callback SI_API.onChatEnded

Triggered when an active chat session is ended.

JavaScript
function onSIApiReady() {
  SI_API.onChatEnded = function() {
    // Show feedback survey
    showSurveyModal();
  };
}

Ready to integrate?

Start your free trial and get your code snippet to begin using the API.