0.0.18-beta.2 • Published 2 years ago

@sprinklrjs/business-components-react v0.0.18-beta.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

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

0.0.18-beta.2

2 years ago

0.0.18-beta.1

2 years ago

0.0.17-beta.3

2 years ago

0.0.17-beta.2

2 years ago

0.0.17-beta.1

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago