npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@microsoft/ocsdk

v0.5.22-main.27b39ce

Published

Microsoft Omnichannel SDK

Readme

Omnichannel SDK

npm version Release CI

This repo contains the source code for getting up and running with the Omnichannel SDK on the web using standard web technologies and on mobile using React Native.

Getting Started

Prerequisites

Installation

npm install

Build

Load SDK in memory and watches the changes for development

npm run watch

Build SDK for development

npm run build:dev

Build SDK for production

npm run build:prod

Check lint rules

npm run lint
```console
Lint checks is enabled by default in watch mode.

# Examples

### Initialize SDK

```js
const params = {
 orgUrl: '',
 orgId: '',
 widgetId: '',
}

const ocsdk = Microsoft.CRM.Omnichannel.SDK.SDKProvider.getSDK(params);
window.ocsdk = ocsdk;

Initialize SDK with custom configuration

const params = {
 orgUrl: '',
 orgId: '',
 widgetId: '',
}

const configuration = {
  getChatTokenRetryCount: 35,
  getChatTokenTimeBetweenRetriesOnFailure: 10000,
  maxRequestRetriesOnFailure: 5
};

const ocsdk = Microsoft.CRM.Omnichannel.SDK.SDKProvider.getSDK(params, configuration);
window.ocsdk = ocsdk;

Get Chat Config

// Manually generate request id
const requestId = Microsoft.CRM.Omnichannel.SDK.Util.uuidv4();
try {
 const config = await window.ocsdk.getChatConfig(requestId);
 // success
} catch {
 // failure
}

// Auto generate request id
try {
 const config = await window.ocsdk.getChatConfig();
 // success
} catch {
 // failure
}

Get Chat Token

// Manually generate request id
const requestId = Microsoft.CRM.Omnichannel.SDK.Util.uuidv4();
try {
 const chatToken = await window.ocsdk.getChatToken(requestId);
 // success
} catch {
 // failure
}

// Auto generate request id
try {
  const chatToken = await window.ocsdk.getChatToken();
  const {requestId} = chatToken; // Request ID auto generated used to getChatToken
  // success
} catch {
  // failure
}

Session Init

const requestId = Microsoft.CRM.Omnichannel.SDK.Util.uuidv4();
const optionalParams = {
  authenticatedUserToken: '',
  getContext: true, // Automically gets browser, device, location & os info
  initContext: { // Optional init context to pass
    locale: '', // 'en-us' by default if not set
    originalurl: '', // window.href.location by default
    os: '',
    browser: '',
    device: '',
    longitude: '',
    latitiude: '',
    preChatResponse: {}
  }
};

try {
 await window.ocsdk.sessionInit(requestId, optionalParams);
 // success
} catch {
 // failure
}

Session Close

const requestId = Microsoft.CRM.Omnichannel.SDK.Util.uuidv4();
const optionalParams = {
  authenticatedUserToken: '',
};

try {
 await window.ocsdk.sessionClose(requestId, optionalParams);
 // success
} catch {
 // failure
}

Submit PostChat Response

const requestId = Microsoft.CRM.Omnichannel.SDK.Util.uuidv4();
const postChatResponse = {};
const optionalParams = {
  authenticatedUserToken: '',
};

try {
 await window.ocsdk.submitPostChatResponse(requestId, postChatResponse, optionalParams);
 // success
} catch {
 // failure
}

Get Chat Transcripts

const requestId = Microsoft.CRM.Omnichannel.SDK.Util.uuidv4();
const chatId = ''; // Chat thread ID
const token = ''; // Skype token
const optionalParams = {
  authenticatedUserToken: '',
};

try {
 const response = await window.ocsdk.getChatTranscripts(requestId, chatId, token, optionalParams);
 // success
} catch {
 // failure
}

Email Transcript

const requestId = Microsoft.CRM.Omnichannel.SDK.Util.uuidv4();
const token = ''; // Skype token
const emailRequestBody = { // Email body
  ChatId: '', // Chat thread ID
  EmailAddress: '[email protected]',
  DefaultAttachmentMessage: '',
  CustomerLocale: 'en-us'
};
const optionalParams = {
  authenticatedUserToken: '',
};

try {
 await window.ocsdk.emailTranscript(requestId, token, emailRequestBody, optionalParams);
 // success
} catch {
 // failure
}

Fetch Data Masking Info

// Manually generate request id
const requestId = Microsoft.CRM.Omnichannel.SDK.Util.uuidv4();
try {
  const response = await window.ocsdk.fetchDataMaskingInfo(requestId);
  // success
} catch {
  // failure
}

// Auto generate request id
try {
  const response = await window.ocsdk.fetchDataMaskingInfo();
  // success
} catch {
  // failure
}

SDK Configuration

These are the available config options with its default values for the SDK.

{
  /**
   * Number of times a getchattoken request is retried.
   */
  getChatTokenRetryCount: 35,
  /**
   * Time in milliseconds between two successive getchattoken retry requests.
   */
  getChatTokenTimeBetweenRetriesOnFailure: 10000,
  /**
   * Maximum number of request retries before failing.
   */
  maxRequestRetriesOnFailure: 5,
}

Releasing

See docs/RELEASING.md for how to publish new versions to npm.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.