Skip to content
JavaScript SDK for Webex Teams
JavaScript Shell Python Dockerfile
Branch: master
Clone or download

Latest commit

Webex Publisher
Latest commit bdd477e Apr 1, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci chore(circleci): add pagerduty to gating jobs Mar 30, 2020
.github build: add code owners to all files [skip ci] Mar 30, 2020
.vscode chore(vscode): update eslint autoformat on save setting Dec 24, 2019
docker/builder chore(node): upgrade to lts/dubnium Dec 24, 2019
docs docs(api): update docs [skip ci] Apr 1, 2020
documentation chore(samples): use webex.min.js instead of bundle.js Mar 25, 2020
packages/node_modules chore(release): v1.80.166 [skip ci] Apr 1, 2020
scripts chore(bin-sauce-connect): deprecate @webex/bin-sauce-connect Aug 2, 2019
tooling fix(tooling): stop yargs test command from setting NODE_ENV Mar 25, 2020
wdio.helpers.d chore(wdio): rename browserSpock/Mccoy to browserChrome/Firefox Mar 18, 2020
webpack chore(tooling): append u2c data to all catalogs Aug 15, 2019
.babelrc chore(mobile): reconfigure babel for better mobile and browser suppor… Oct 24, 2019
.codeclimate.yml refactor(webex): rename repo and main package to webex Jun 9, 2019
.coveralls.yml chore(build): configure coveralls Jul 22, 2016
.editorconfig feat(ciscospark): Initial commit for github.com Jul 7, 2016
.env.default fix(i-p-conversation): add defaults to env Oct 24, 2019
.eslintignore build(script): update readmes and script output folder Dec 11, 2018
.eslintrc.yml refactor(rebranding): rebase + ediscovery and meetings fixes May 9, 2019
.gitattributes chore(tooling): tell github where our code is Apr 7, 2017
.github-todos feat(ciscospark): Initial commit for github.com Jul 7, 2016
.gitignore chore(umd): generate umd bundle with samples webpack config Mar 25, 2020
.gitmodules feat(ciscospark): Initial commit for github.com Jul 7, 2016
.jscsrc feat(ciscospark): Initial commit for github.com Jul 7, 2016
.jsdoc.json refactor(webex): rename repo and main package to webex Jun 9, 2019
.nvmrc chore(node): upgrade to lts/dubnium Dec 24, 2019
.tern-project feat(ciscospark): Initial commit for github.com Jul 7, 2016
.yo-rc.json feat(ciscospark): Initial commit for github.com Jul 7, 2016
BUILD-ISSUES.md docs(readme): added more build dependency info Apr 12, 2019
CONTRIBUTING.md chore(readme): update samples setup [skip npm] Mar 19, 2020
LICENSE refactor(webex): rename repo and main package to webex Jun 9, 2019
README.md chore(umd): update readmes with cdn links to umd build Mar 25, 2020
SCRIPTS.md docs(scripts): add samples automation docs Feb 26, 2020
UPGRADING.md docs(UPGRADING): fix Plugins section Jun 13, 2019
appveyor.yml chore(tooling): do not build samples on windows Nov 21, 2017
browsers-ng.js chore(circleci): create new pipeline with CircleCI and add new Github… Jul 25, 2019
browsers.js chore(circleci): create new pipeline with CircleCI and add new Github… Jul 25, 2019
commitlint.config.js chore(tooling): upgrade commitlint Apr 5, 2018
deps.js refactor(webex): rename repo and main package to webex Jun 9, 2019
jsconfig.json fix(plugin-phone): update video toggle flow Jul 2, 2018
karma-ng.conf.js refactor(karma): ability to create junit report outside of sauce [ski… Nov 26, 2019
netlify.toml fix(samples): tweak webpack environment parameter Mar 7, 2019
package-lock.json chore(umd): generate umd bundle with samples webpack config Mar 25, 2020
package.json fix(eslint): add umd bundle to lint ignore [skip npm] Mar 26, 2020
run.sh chore(node): upgrade to lts/dubnium Dec 24, 2019
sauce.py chore(tooling): append u2c data to all catalogs Aug 15, 2019
test.py chore(tooling): append u2c data to all catalogs Aug 15, 2019
wdio.conf.js chore(wdio): rename browserSpock/Mccoy to browserChrome/Firefox Mar 18, 2020
webpack.config.js chore(samples): use webex.min.js instead of bundle.js Mar 25, 2020

README.md

webex-js-sdk

Greenkeeper badge

npm license Build status

The Cisco Webex JS SDK

Upgrading from Cisco Spark to Webex?

This is a monorepo containing all officially maintained Cisco Webex JS SDK modules in the same repo. webex is a collection of node modules targeting our external APIs.

Install

We test against the Active LTS (Long Term Support) version of Node.js and use npm@6 to run security audits.

To install the latest stable version of the SDK from NPM:

npm install --save webex

Usage

To use the SDK, you will need Cisco Webex credentials. If you do not already have a Cisco Webex account, visit Cisco Webex for Developers to create your account and retrieve your access token.

See the detailed docs for more usage examples.

const Webex = require(`webex`);
const webex = Webex.init({
  credentials: {
    access_token: <your webex teams access token>
  }
});

// Create a room with the title "My First Room"
// Add Alice and Bob to the room
// Send a **Hi Everyone** message to the room
webex.rooms.create({ title: `My First Room` }).then(room => {
  return Promise.all([
    webex.memberships.create({
      roomId: room.id,
      personEmail: `alice@example.com`
    }),
    webex.memberships.create({
      roomId: room.id,
      personEmail: `bob@example.com`
    })
  ]).then(() =>
    webex.messages.create({
      markdown: `**Hi Everyone**`,
      roomId: room.id
    })
  );
});

A note on browser usage

We provide a built, minified version of the SDK, that includes window.Webex. You can access it via unpkg, jsdelivr, or gitcdn.xyz.

<!-- unpkg -->
<script crossorigin src="https://unpkg.com/webex/umd/webex.min.js"></script>
<!-- jsdelivr -->
<script crossorigin src="https://cdn.jsdelivr.net/npm/webex/umd/webex.min.js"></script>
<!-- gitcdn -->
<script crossorigin src="https://gitcdn.xyz/repo/webex/webex-js-sdk/master/packages/node_modules/webex/umd/webex.min.js"></script>

If you're already using a bundler (like Webpack or Rollup) you can simply import/require the package and use the above snippet and assign the initialized webex variable to window.webex.

For a quick example, we'll use Parcel to bundle the SDK for a website. For any more information and questions on how to use Parcel, please head to their website.

  1. Create index.js.
import { init as initWebex } from 'webex';

// Initialize the SDK and make it available to the window
const webex = (window.webex = initWebex({
  credentials: {
    access_token: <your webex teams access token>
  }
}));

// Create a room with the title "My First Room"
webex.rooms
  .create({
    title: 'My First Room!'
  })
  .catch((error) => {
    console.error(error);
  });

// Filter for "My First Room" from the last 10 rooms
webex.rooms
  .list({
    max: 10
  })
  .then((rooms) => {
    // Destructure room properties for its id (aliased to roomId) and title
    const { id: roomId, title } = rooms.items.filter(
      room => room.title === 'My First Room!'
    )[0];

    // Post message "Hello World!" to "My First Room!"
    webex.messages.create({
      roomId,
      text: 'Hello World!'
    });

    // Log the the room name and the message we created
    return webex.messages
      .list({ roomId, max: 1 })
      // Destructure promised value to get the text property from the first item in items array
      .then(({ items: [{ text }] }) =>
        console.log(`Last message sent to room "${title}": ${text}`)
      );
  })
  .catch((error) => {
    console.error(error);
  });
  1. Create index.html .
<html>
  <head>
    <title>Webex SDK for Browsers</title>
  </head>
  <body>
    <script src="./index.js"></script>
  </body>
</html>
  1. Add a compatible browser version for parcel to compile for
  • Add the browserlist property to your package.json. We're using the last two versions of both Chrome and Firefox in this example
"browserslist": [
  "last 2 Chrome versions"
  "last 2 Firefox versions"
]

NOTE: This is needed for parcel to correctly compile dependencies the SDK uses for the browser environment. The SDK uses the last 2 versions of Chrome and Firefox, so we're including it here too. You can use browserl.ist to configure your own setup

  1. Run parcel index.html in your terminal.
  2. Go to http://localhost:1234 and open the developer console to see the output.

Still using webex/env or ciscospark/env?

Samples

Sample code can be found in packages/node_modules/samples. You can demo them by going to js.samples.s4d.io/ or you can run them yourself by following this guide in the Contribution Guide

Samples Hosted
Samples code js.samples.s4d.io/

Contribute

Pull requests welcome. Please see CONTRIBUTING.md for more details about building the packages and submitting pull requests for suggested changes.

License

© 2016-2019 Cisco and/or its affiliates. All Rights Reserved.

See LICENSE for details.

You can’t perform that action at this time.