Examples of Custom Behavior
Trigger Rep.ai from buttons
Custom dial trigger
<button onclick="RepAI('dial')">Need live help?</button>var button = document.getElementById('my-button');
button.addEventListener("click", function() {
RepAI("dial");
});Require permission before initializing
<div id="dialog-confirm" title="Receive calls?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:12px 12px 20px 0;"></span>
Would you like to opt-in to receiving calls from our team during your session?</p>
</div>
<script>
// Inject the RepAI API.
!function(w,d){function e(e,n){w.RepAI.q=w.RepAI.q||[],w.RepAI.q.push([e,n])}if(!w.RepAI){var t=function(n){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];e(n,i)};["init","identify","dial","alert","bookMeeting","hide","show","expand","collapse","connect","disconnect"].forEach((function(i){t[i]=function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];e(n,i)}})),w.RepAI=t}var s=d.createElement("script");s.id="rep-ai-script",s.src="https://cdn.servicebell.com/main.js",s.async=1;var i=d.getElementsByTagName("script")[0];i.parentNode.insertBefore(s,i)}(window,document);
// Pop open jQuery dialog to confirm they're OK with being called.
$(function () {
$("#dialog-confirm").dialog({
resizable: false,
height: "auto",
width: 400,
modal: true,
buttons: {
Accept: function () {
RepAI("init", "YOUR_CLIENT_KEY_HERE");
$(this).dialog("close");
},
Decline: function () {
$(this).dialog("close");
},
},
});
});
</script>Handling missed calls
Show expanded widget, hide on collapse
Listen for initialization or error
Last updated
Was this helpful?