Skip to content
FacebookYouTubeX (Twitter)

JavaScript API - Methods

Pingstreams provides a Pingstreams JavaScript object that responds to a few methods. These allow you to update widget without a page refresh and interact with the messenger window.

This will open the widget:

window.Pingstreams('open');

This will minimize the widget:

window.Pingstreams('close');

This will hide the widget:

window.Pingstreams('hide');

This will show the widget:

window.Pingstreams('show');

This will clear the widget html elements from the DOM:

window.Pingstreams('dispose');

If your app is characterized by very few page refreshes (ie., content is swapped out on the client side but no page refresh happens, Angular, React, jQuery, etc..) and lots of asynchronous JS, you’ll need to update Pingstreams when your user’s data changes. A reInit call simulates a page refresh, causing Pingstreams to reload the widget and all the configurations.

window.Pingstreams('reInit');

This method allow you to restart widget with the same user’s data without make a new authentication. This also maintains all the configurations.

window.Pingstreams('restart');

This method make a signin anonymously

window.Pingstreams('signInAnonymous');

This method make a signin using a JWT Custom Token as described here.

window.Pingstreams('signInWithCustomToken', customJwt);

This will logout the widget:

window.Pingstreams('logout');

This will show the widget callout if it is not open:

window.Pingstreams('showCallout');

This parameter configures the PreChatForm visibility:

window.Pingstreams('setPreChatForm', true|false);

This method allow you to customize preChatFormJson property, and change preChatForm structure if preChatForm is still active (ensure preChatForm value is set to true, otherwise use window.Pingstreams(‘setPreChatForm’, true) method before call setPreChatFormJson ). This method accept an Array (see docs for more detail about customize it):

window.Pingstreams('setPreChatFormJson', customFormArray);

This method allow you to get current preChatForm Json array used in the preChatForm component when is active (check preChatForm value is set to true):

window.Pingstreams('getPreChatFormJson');

You can change a value to the Pingstreams Widget parameter. Pass an object in the form of key/value, where key represent the name of the property you want to modify, and value is the new value you want to set:

window.Pingstreams('setParameter', {key: string, value: string});

Set new value to Widget attribute parameter

Section titled “Set new value to Widget attribute parameter”

You can change a value to the Pingstreams Widget attribute parameter. Pass an object in the form of key/value, where key represent the name of the property you want to modify, and value is the new value you want to set:

window.Pingstreams('setAttributeParameter', {key: string, value: string});

You can programmatically start a new conversation:

window.Pingstreams('startConversation');

You can programmatically open an already existing conversation by id in the form of 'support-group-'+<project_id>+'-'+uuid

window.Pingstreams('openConversationById', conversation_id);

You can programmatically clear saved session data:

window.Pingstreams('clearStorage');