Controlling the Widget
Use the Javascript API to control widget behaviors
The RepAI
API exposes a few methods that allow you to control the widget without user interaction. This can be useful for controlling the user experience around users requesting calls, or hooking up the widget to custom UI elements.
RepAI("init", api_key, options?)
RepAI("init", api_key, options?)
You can add options to the init
call to specify how the widget should render initially.
Note that some of these options overlap with the configurations set via your organization's widget appearance settings page. If any of these arguments are provided programmatically, the JS options will take precedence over the appearance settings.
RepAI("show")
RepAI("show")
Shows the widget if it's hidden. If you want to start the widget hidden and programmatically show later, initialize with hidden: false
.
RepAI("hide")
RepAI("hide")
Hides the widget if it's visible.
RepAI("expand")
RepAI("expand")
Expands the widget if it's visible.
RepAI("alert", options?)
RepAI("alert", options?)
Puts the visitor into an alert state, which displays them prominently on the dashboard, and sends all available admins a push notification. You can configure the notification with the optional options object argument. Alerting will cause no visual change for the visitor, it's only for dashboard alerting purposes.
RepAI("dial")
RepAI("dial")
Puts the visitor into the dialing state, which displays them prominently on the dashboard, sends all available admins a push notification, and displays to the user the dialing state. This is equivalent to the user clicking on the widget to dial. The widget will always be visible when dialing, even if it was hidden.
RepAI("bookMeeting")
RepAI("bookMeeting")
Immediately opens the widget to the book meeting view that they normally see if the dial timer times out, or if no admins are available. Either shows them an email submission form, or the Calendly widget if Calendly is configured.
RepAI("connect")
RepAI("connect")
Triggers the widget to connect to the Rep.ai server if it wasn't already connected. This is only used in conjunction with { connect: false }
or RepAI("disconnect")
as the widget will normally connect by default after calling RepAI.init()
RepAI("disconnect")
RepAI("disconnect")
Triggers the widget to disconnect from the Rep.ai server if it wasn't already disconnected. This should typically be used in conjunction with RepAI.connect()
.
Note that if your Rep.ai installation initializes with { connect: true }
or doesn't specify a connect parameter, the widget will immediately connect on the next page load or refresh unless RepAI("disconnect")
is called again.
RepAI("showPopup", options?)
RepAI("showPopup", options?)
Triggers a small popup to appear above the widget, or a larger modal to take over the screen, to invite visitors to use the Rep.ai widget to start a call. Either of them will only show up if the widget is currently collapsed, and agents are available to take calls. Otherwise there will be no effect.
RepAI("startJourney", options)
RepAI("startJourney", options)
This asynchronous call will attempt to start the visitor on the journey for the provided ID. If the journey is not found or not active, the api call will not succeed. If the visitor is currently on a different journey, it will be cancelled in favor of the one specified in the journeyId
option parameter. If the visitor is already on the specified journey, the call will return true
without restarting the journey.
This function returns a Promise<boolean>
representing whether the visitor has been (or already is) started on the journey. It will log failures to the browser console.
Last updated