Home > How do I programmatically start proactive chat on some pages?
(Last Updated On: August 4, 2021)
The purpose of this article is to provide a comprehensive overview of how to programmatically start proactive chat on some pages.
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.
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:
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:
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?');
setTimeout('SnapABug.openProactiveChat(true, false, &amp;quot;Hey there, anything I can help you with?&amp;quot;);', 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);
Published January 12, 2012