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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sprinklrjs/business-components-react

v0.0.18-beta.2

Published

React components that external applications can embed in their apps.

Downloads

10

Readme

Sprinklr Business React Components

React components that external applications can embed in their apps.

Getting Started

Install the npm package

yarn add @sprinklrjs/business-components-react

Usage

import { OTAProvider, CaseStream, CaseTimeline, ActionTypes } from '@sprinklrjs/business-components-react';

const OTA = '#####';
// OR
const OTAPromise = fetch('/sprinklr-ota');

const Component = () => {
  const [caseNumber, setCaseNumber] = useState(undefined);

  const handleAction = action => {
    switch (action.type) {
      case ACTION_TYPES.SELECT_CASE:
        setCaseNumber(action.payload.caseNumber);
        break;
      default:
        break;
    }
  };

  return (
    <OTAProvider ota={OTAPromise /* OR OTA */}>
      <CaseStream onAction={handleAction} />
      {caseNumber ? <CaseTimeline caseNumber={caseNumber} /> : null}
    </OTAProvider>
  );
};

Components

OTAProvider

This component is used to provide the access token to all the UI Components. All Srinklr business components must be wrapped with this Provider so that they are able to authenticate and render properly. Pass to it, either the access token or a promise that resolves to an acccess token.

import { OTAProvider, CaseTimeline } from '@sprinklrjs/business-components-react';
const Component = () => {
  return (
    <OTAProvider ota={OTAPromise /* OR OTA */}>
      <CaseTimeline caseNumber={caseNumber} />
    </OTAProvider>
  );
};

CaseConversation

This component shows the transcript of the conversation that took place between the Agent/Bot/IVR with the customer. For a live call it updates on a real time basis.

import { OTAProvider, CaseConversation } from '@sprinklrjs/business-components-react';
const Component = () => {
  return (
    <OTAProvider ota={OTAPromise /* OR OTA */}>
      <CaseConversation caseNumber={caseNumber} />
    </OTAProvider>
  );
};

CaseTimeline

This component shows a list of previous cases that the customer had with the brand.

import { OTAProvider, CaseTimeline } from '@sprinklrjs/business-components-react';

const Component = () => {
  return (
    <OTAProvider ota={OTAPromise /* OR OTA */}>
      <CaseTimeline caseNumber={caseNumber} />
    </OTAProvider>
  );
};

CaseStream

This component shows a collection of cases basis certain pre-defined condition/conditions i.e. open cases, cases assigned to an agent, all cases etc.

import { OTAProvider, CaseStream } from '@sprinklrjs/business-components-react';
const Component = () => {
  const handleAction = action => {
    switch (action.type) {
      case ACTION_TYPES.SELECT_CASE:
        setCaseNumber(action.payload.caseNumber);
        break;
      default:
        break;
    }
  };

  return (
    <OTAProvider ota={OTAPromise /* OR OTA */}>
      <CaseStream onAction={handleAction} />
    </OTAProvider>
  );
};

The handleAction function expects the following Actions -

//When used selects a case
type SelectCaseAction = {
  type: typeof ActionTypes.SELECT_CASE,
  payload: {
    caseNumber: number,
  },
};
//When user clicks on collapse stream icon
type CollapseAction = {
  type: typeof ActionTypes.COLLAPSE_CASE_STREAM,
};
CaseStreamAction = SelectCaseAction | CollapseAction;

CaseContactInsights

This component takes customer past interactions with the brand into account to generate useful insights. For example: Customer’s preferred mode of contact.

import { OTAProvider, CaseContactInsights } from '@sprinklrjs/business-components-react';
const Component = () => {
  return (
    <OTAProvider ota={OTAPromise /* OR OTA */}>
      <CaseContactInsights caseNumber={caseNumber} />
    </OTAProvider>
  );
};

Voice Widget

This component integrates voice widget which allows agents receive inbound voice calls as well as allows them to make outbound voice calls.


import {OTAProvider, Voice, sprVoice} from '@sprinklrjs/business-components-react';

const Component = () => {
    const handleVoiceInitialization = useCallback(() => {
        sprVoice.subscribe('incomingCall', () => {
            console.log('incoming call');
        })
    }, []);

    return (
        <OTAProvider ota={OTAPromise /* OR OTA */}>
            <Voice widgetId={widgetId} onInitialized={handleVoiceInitialization}/>
        </OTAProvider>
    );
}

The widget renders in a collapsed state by default. Clicking on it expands it to show the dial-pad.
When an incoming call is received, the widget expands to provide CTAs to accept or reject the call.
When a call is connected, call controls will appear.

Triggering commands imperatively via sprVoice

sprVoice can be used to expand or collapse the voice widget. It also allows subscribing to events happening inside the voice widget.

import {sprVoice} from '@sprinklrjs/business-components-react';
  1. sprVoice.open() - To expand the voice widget.
  2. sprVoice.close() - To collapse the voice widget.
  3. sprVoice.subscribe(event, callback) - To subscribe to events ('incomingCall' | 'opened' | 'closed') emitted from the voice widget. Returns a function to unsubscribe. Note that the subscriptions should be setup only after the widget has been initialized ( use onInitialized prop ).

Useful Links