Webex Embedded Apps SDK (@webex/embedded-app-sdk)

Table of Contents


Getting Started

To get started on using the SDK, please visit the API reference docs.


Kitchen Sink App


What's new in 2.0?

NPM Availability

In addition to existing CDN build, we now have the main Application object available as an npm package. For more details, see the next section.

Using the SDK via NPM

Installing the SDK

npm install --save @webex/embedded-app-sdk@2.0.0-beta.1

This will create an entry in your package.json like this:

{
"name": "webex-embedded-app-sample",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@webex/embedded-app-sdk": "^2.0.0-beta.1"
}
}

Using the SDK

import Application from '@webex/embedded-app-sdk';
const app = new Application();
await app.onReady();

Access anything under the app object as per the API reference. This can later be bundled with your app by using any bundling tool like webpack or rollup.

Using the SDK via CDN

Including the SDK

Add the following code in your index.html

<script src='https://unpkg.com/@webex/embedded-app-sdk@2.0.0-beta.1'></script>

The SDK is now included in your app.

Using the SDK

const app = new window.webex.Application();
await app.onReady();

Access anything under the app object as per the API reference.

Sidebar Apps APIs

  • We have sidebar-related APIs, which also include call monitoring-related APIs
  • It is going to be of massive help to move away from Jabber and start using Webex Calling
  • More about Sidebar Apps APIs are documented here.

Rate limit on requests

Requests from the Embedded App SDK are rate limited by the native client in the following ways:

  • Initialization of the SDK is rate limited at 5 requests every 5 minutes.
  • Other requests from the SDK are rate limited at 20 requests per minute.

Log levels

The Embedded App SDK 2.x allows the user to set and modify the log level at Application instance creation or at a later time. Default log level is set to INFO.

While creating application instance

const config = {
logs: {
logLevel: 0 //INFO: 0, WARN: 1, ERROR: 2, SILENT: 3
}
}
const app = new window.Webex.Application(config); //CDN
OR
const app = new Application(config); //NPM

Using log property on application instance

app.log.updateLogLevel(0);  //INFO: 0, WARN: 1, ERROR: 2, SILENT: 3

Migration from 1.x to 2.x

Movement of main Webex.Application object

  • The main Webex.Application object is removed and moved to webex.Application

In 1.x SDK

const app = new window.Webex.Application();

In 2.x SDK

const app = new window.webex.Application();

Mentions of webex.application object

The properties of webex.application are now private and no longer accessible

In 1.x SDK

const about = webex.application.about;
const capabilities = webex.application.capabilities;
const deviceType = webex.application.deviceType;

In 2.x SDK

const app = new window.webex.Application();
const about = app.about;
const capabilities = app.capabilities;
const deviceType = app.deviceType;

The above list is not exhaustive, and other properties will also require the same change as shown above. All the properties, accessors, methods, and events are documented in the Application class.

Get user API

The user object is now a static object in 2.x SDK and can be directly accessed via the SDK; therefore, the context.getUser() method is no longer available.

In 1.x SDK

const app = new window.Webex.Application();
app.context
.getUser()
.then((u) => {
log("getUser()", u);
})
.catch((error) => {
log(
"getUser() promise failed with error",
Webex.Application.ErrorCodes[error]
);
});

In 2.x SDK

const app = new window.webex.Application();
await app.onReady();
const user = app.application.states.user;

User info changed event

There are no real-time updates for the user object, so the event user:infoChanged is no longer emitted.

In 1.x SDK

const app = new window.Webex.Application();
app.onReady().then(() => {
app.listen()
.then(() => {
app.on("user:infoChanged", (user) => {
console.log("User object modified. New Information:", user);
})
})
.catch((reason) => {
console.error("listen: fail reason=" + webex.Application.ErrorCodes[reason]);
});
});

In 2.x SDK

The event is removed and won't be emitted. Any instances of the above code must be removed.