JavaScript SDK

The source of the examples below are on github.com/circuit and are hosted via rawgit. When running the examples you will be asked to sign in with a Circuit sandbox account. You can register for a free account on the Circuit Portal.

API Documenation

Teaser example to logon and fetch conversations:

// Create the client with the client_id (aka app key), scope and optionally a redirect_uri
let client = new Circuit.Client({
  client_id: 'your app key',
  scope: 'READ_USER_PROFILE,READ_CONVERSATIONS'
});

// Logon using OAuth2, then retrieve the logged on user's conversations
client.logon()
.then(user => console.log('Successfully authenticated as ' + user.displayName))
.then(client.getConversations)
.then(conversations => conversations.forEach(c => console.log(c.convId)))
.catch(err => console.error(err));
                        

See OAuth 2.0 for information on how to register an app.

This codepen blog explains some recent changes to the JS SDK. The codepen examples at codepen.io/circuit are deprecated. Use the examples shown on this page instead.

JS Bin examples

Short examples demonstrating one or more particular APIs. You can view the source, or clone your own JS Bin using the link at the top right of the live example. A sandbox account is required to run the live examples. JS Bin examples use OAuth 2.0.

Live Example Description
Get Threads and Comments Retrieve 25 most recent conversations and display them in a list. When selecting a conversation, retrieve their 50 most recent threads and display them in a list. When selecting a thread, show the 20 most recent comments.
Create conference bridge Create a new conversation for a conference bridge, gets the conference details and waits for participants to join. Once other participants join the audio conference is established. No video in this example.
Disable remote audio Lookup active conferences, then join first one and disable the incoming audio stream.
Mute mic/speaker of webclient Lookup active call on webclient, then mute mic and speaker for that call on that webclient.
OAuth 2.0 Client Credentials Grant Testing login and auto token renewal for OAuth 2.0 Client Credentials Grant. Client Credentials Grant should ONLY be used by server side applications such as Node.js BOTs.

Github examples

Circuit-like web-app

Circuit-like app built with vue.js and Circuit JS SDK. Showcases several different APIs. RTC APIs still to be added.

Live example Source
Introduction example

Logon using OAuth2, read most recent conversation. Defines injectors and shows conversation with extended injector attributes. Listens to various events.

Live example Source
Group Call: video and screenshare

This example shows how to start, join or leave a conference call. Also allows to toggle video or screenshare. For screenshare the Circuit SDK Chrome Extension is required.

Live example Source
Complete Messaging Examples (AngularJS)

Shows complete messaging functionality. Allow to select a conversation to send a message to, upload files, or create a new conversation.

Live example Source
OAuth2 Login

This example shows how to use the JS SDK to login with OAuth and fetch the conversation IDs.

Live example Source
Telephony (PSTN) call

Make outgoing phone calls to any regular telephone. Telephony Connector needs to be setup for your tenant.

Live example Source
Direct Call: audio and video

This example shows how to start an audio/video direct call, or auto accept an incoming call.

Live example Source
Add participant to call

Start a conference and dial out either a PSTN number, a Circuit user, or ring all conversation members.

Live example Source
Share HTML5 Canvas

This example shows a schematic in a HTML5 canvas and allows drawing on top of it and shares the combined image in the call. The application can use the new HTMLCanvasElement.captureStream API available in Chrome and Firefox to capture a stream from a canvas. Note that Chrome has an issue with compression which causes WebRTC to reduce the resolution, or not even show the drawing. Use FireFox in the meantime.

Live example Source