Home > How do I programmatically start the proactive chat on some pages?

Categories: |


(Last Updated On: July 6, 2017)

You will have to setup a rule (or some rules) that matches the URLs for these pages and therefore have a proactive chat message prompt defined. The delay should be long enough so that the engagement is not done by the timer but instead by the API call.

Just make this call from your JavaScript logic to start a proactive chat when appropriate:

SnapABug.openProactiveChat();

Note: that this function call will have no effect when agents are unavailable or when the visitor has closed a SnapEngage window on your site in the last hour.

If you want to have SnapEngage ignore the previous closed chat window by the visitor, and always show the proactive chat prompt on this API call, add a first parameter set to true:

SnapABug.openProactiveChat(true);

In this mode, you could have the proactive chat API call used when someone clicks a button “chat with us”, so you may want to have the fallback to the offline form. For that, just add another parameter set to true:

SnapABug.openProactiveChat(true, true);

Finally, if you are managing your proactive chat engagement logic on your own back-end, you probably do not want to have to setup rules in the SnapEngage dashboard for the messages. You can add a 3rd parameter with the message as a string. For instance:

SnapABug.openProactiveChat(true, false, 'Hello, can I help you with our setup process?');

If you want programmatically start the proactive chat on a delay you can do this by adding this call to your JavaScript:

setTimeout('SnapABug.openProactiveChat(true, false, "Hey there, anything I can help you with?");', 10 * 1000);

This is in milliseconds, so the example will show the proactive chat after 10 seconds. (So for 5 seconds change it to 5 * 1000);

Did you find this article helpful?

Not HelpfulNeeds WorkSo-soHelpfulVery Helpful (2 votes, average: 5.00 out of 5)
Loading ... Loading ...

Published January 12, 2012