3.6.0 • Published 1 year ago

@shelf/agent-assist-sdk v3.6.0

Weekly downloads
83
License
MIT
Repository
github
Last release
1 year ago

@shelf/agent-assist-sdk CircleCInpm.io

The Shelf Agent Assist SDK allows you to integrate Shelf widget into any platform and provide agents with real-time recommendations, accurate search and content from Shelf knowledge base.

Install

As npm module

$ npm install @shelf/agent-assist-sdk

or

$ yarn add @shelf/agent-assist-sdk

As script

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@shelf/agent-assist-sdk@:tag-version:/lib/agent-assist.min.js"></script>

API reference

Properties:

SDK includes the following methods:

SDK.initialize

Initialize iframe in provided element and set config for agent assist widget. All other methods should be called after initialize is resolved

initialize(element: HTMLElement, config: InitializeConfig): Promise

Parameters:

NameTypeDefault valueDescription
elementHTMLElement-Element in which will be rendered Shelf iframe
configInitializeConfig-Config of widget

Returns: Promise\

InitializeConfig

{
  suggestions?: {
    enabled: boolean; // enabled by default
    sendToChatButton?: {
      enabled: boolean; // false by default
    };
    copySnippetButton?: {
      enabled: boolean; // false by default
    };
    autoParsedHashtags?: {
      enabled: boolean; // disabled by default
    };
  };
  gem?: {
    autoParsedHashtags?: {
      enabled: boolean; // disabled by default
    };
  };
  favorites?: {
    enabled: boolean; // enabled by default
  };
  workflow?: {
    enabled: boolean; // disabled by default
    sendToChatButton?: {
      enabled: boolean; // disabled by default
    };
    copySnippetButton?: {
      enabled: boolean; // disabled by default
    };
  };
  telemetry: {
    systemName: string; // 'kustomer' | 'genesys_cloud' | 'amazon_connect';
  };
  shelfDomain: 'shelf.io'
}

suggestions

Optional suggestions:

NameTypeDefaultDescription
enabledbooleantrueWhenever to display Agent Assist tab. Note: Agent Assist should be enabled in Agent Assist configuration
sendToChatButton?.enabledbooleanfalseWhenever to display Send to Chat on suggestions tab
copySnippetButton?.enabledbooleanfalseWhenever to display Copy snippet on suggestions tab

favorites

Optional favorites: { enabled?: boolean }

NameTypeDefaultDescription
enabledbooleantrueWhenever to display Favorites tab. Note: Agent Assist + Favorites should be enabled in Agent Assist configuration

telemetry

Required telemetry: { systemName: string }

NameTypeDefaultDescription
systemNamestring-Name of the system where Agent Assist SDK is used

shelfDomain

Required shelfDomain: string

NameTypeDefaultDescription
shelfDomainstring-Shelf domain to use. shelf.io - is the only possible value for now

Example

shelf.AgentAssist.initialize(
  document.getElementById('agent-assist-root'),
  {
    favorites: {
      enabled: true
    }
    suggestions: {
     enabled: true,
     sendToChatButton: {
        enabled: true
     },
     displayCopyButton: {
        enabled: false
     }
    },
    shelfDomain: 'shelf.io'
  })

getSuggestions

Find and display recommendations for one question from Shelf knowledge base. Works only when suggestions are enabled

getSuggestions(question: string[]): Promise

Parameters:

NameType
questionsstring[]

Returns: Promise

Example

shelf.AgentAssist.getSuggestions('Do I need to wear masks?')

clearSuggestions

Clear suggestions data

clearSuggestions(): Promise

Returns: Promise

Example

shelf.AgentAssist.clearSuggestions()

on

Subscribe to agent events. Only one listener could be provided

on(eventName: AgentEvent, handler: (data) => void): void

eventName: \"send-to-chat\" | \"copy-snippet\"

on('send-to-chat`)

Triggered when agent clicks on Send to chat

Example

shelf.AgentAssist.on('send-to-chat', ({text}) => {
    ... use api to send message to integrated platform
})

on('copy-snippet`)

Triggered when agent clicks on Copy snippet

Example

shelf.AgentAssist.on('copy-snippet', ({text}) => {
    ...
})

off

Unsubscribe fom agent events

off(eventName: AgentEvent): void

Example

shelf.AgentAssist.off('send-to-chat')

openTab

Open tab inside agent assist

openTab(tab: AgentAssistTab): void | Promise\

AgentAssistTab: \"suggestions\" | \"search\" | \"gem\" | \"favorites\"

NameType
tabTab

Returns: Promise

Example

shelf.AgentAssist.openTab('suggestions')

request

Allows making custom request to the api

request(params: RequestParams): Promise

Parameters:

NameType
paramsRequestParams

Returns: Promise

RequestParams

{
  url: string;
  method: 'PATCH' | 'POST' | 'DELETE' | 'GET' | 'PUT';
  body?: Record<string, any>;
  headers?: Record<string, any>;
}

Example

// Get current logged user info
shelf.AgentAssist.request({
  url: 'auth/v1/user',
  method: 'GET'
})

updateSession

Updates current agent session with external system info. This is needed to troubleshoot possible issues on Shelf side. On the other hand, this data is analyzed to make the suggestions more relevant for agents

updateSession(payload: UpdateSessionPayload): Promise

Parameters:

NameType
payloadUpdateSessionPayload

Returns: Promise\

UpdateSessionPayload

{
  interactionId?: string;
  agentId?: string;
  participantId?: string;
  participantContext?: Record<string, any>;
}

Example

shelf.AgentAssist.updateSession({
  interactionId?: 'interaction-id',
  agentId?: 'some-agent-id',
  participantContext: {
    contactReason: 'order-missing',
    timestamp: '...',
    ...
  }
})

version

Get the current SDK version

version: string

Example

SDK.version // ex: 1.0.0

agentAssistVersion

Get the version of Shelf Agent Assist

agentAssistVersion: string

Example

SDK.agentAssistVersion // ex: 1.0.0

Examples

  • yarn install
  • yarn dev
  • open browser on http://localhost:8080/

License

MIT © Shelf

3.6.0-beta1.0

1 year ago

3.6.0-beta1

1 year ago

3.4.0

2 years ago

3.2.1

2 years ago

3.6.0

1 year ago

3.3.0

2 years ago

3.5.0

2 years ago

3.2.0

2 years ago

3.0.0

2 years ago

3.1.0-0

2 years ago

3.1.0

2 years ago

2.2.0

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.17.0

2 years ago

1.18.0-0

2 years ago

1.16.0

2 years ago

1.17.0-0

2 years ago

1.16.0-1

2 years ago

1.16.0-0

2 years ago

1.15.0

3 years ago

1.14.0

3 years ago

1.13.0

3 years ago

1.12.0

3 years ago

1.11.0-0

3 years ago

1.11.0

3 years ago

1.10.0

3 years ago

1.9.0

3 years ago

1.8.0

3 years ago

1.8.0-0

3 years ago

1.7.0

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.6.0-0

3 years ago

1.5.0

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.4.0-1

3 years ago

1.3.2-1

3 years ago

1.4.0-0

3 years ago

1.3.2-0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.3.1-3

3 years ago

1.3.1-2

3 years ago

1.3.1-1

3 years ago

1.3.1-0

3 years ago

1.3.0-2

3 years ago

1.3.0-1

3 years ago

1.2.1-0

3 years ago

1.3.0-0

3 years ago

1.2.0

3 years ago

1.2.0-0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.12

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.9

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago