Sample code snippets
Build the experience that you want for your support agents with our powerful agent SDK. Here are some examples of commonly required functionality.
List only relevant sessions or devices using filters
const sessions = await cobrowse.sessions.list({
filter_user_id: 'xxxx'
// other filtering properties are also supported.
// See the API reference for more.
state: ['ended']
})Listen for updates on a session or device
Subscribing to Session resources
const sessions = await cobrowse.sessions.list({
// add your filters in here, e.g.
filter_user_id: 'xxxx', // customData filters start with "filter_"
state: ['ended'] // session property filters
})
// subscribe to updates for these Sessions
sessions.forEach((session) => {
session.subscribe()
session.on('updated', () => console.log('session was updated', session.id)
})Subscribing to Device resources
Control an IFrame embedded in my support agents' portal
IFrame embedsAccess and update the session in the IFrame
Add extra data to a session from the agent side
IFrame embedsAuthentication (JWTs)Completely replace the session UI with my own design
Check the number of active sessions
End the session after a chat/interaction, or after the browser is closed
Leave without ending the session
Last updated