@shelf/agent-assist-sdk v3.6.0
@shelf/agent-assist-sdk
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:
Name | Type | Default value | Description |
---|---|---|---|
element | HTMLElement | - | Element in which will be rendered Shelf iframe |
config | InitializeConfig | - | 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:
Name | Type | Default | Description |
---|---|---|---|
enabled | boolean | true | Whenever to display Agent Assist tab. Note: Agent Assist should be enabled in Agent Assist configuration |
sendToChatButton?.enabled | boolean | false | Whenever to display Send to Chat on suggestions tab |
copySnippetButton?.enabled | boolean | false | Whenever to display Copy snippet on suggestions tab |
favorites
Optional
favorites: { enabled?: boolean }
Name | Type | Default | Description |
---|---|---|---|
enabled | boolean | true | Whenever to display Favorites tab. Note: Agent Assist + Favorites should be enabled in Agent Assist configuration |
telemetry
Required
telemetry: { systemName: string }
Name | Type | Default | Description |
---|---|---|---|
systemName | string | - | Name of the system where Agent Assist SDK is used |
shelfDomain
Required
shelfDomain: string
Name | Type | Default | Description |
---|---|---|---|
shelfDomain | string | - | 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:
Name | Type |
---|---|
questions | string[] |
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\"
Name | Type |
---|---|
tab | Tab |
Returns: Promise
Example
shelf.AgentAssist.openTab('suggestions')
request
Allows making custom request to the api
request(params
: RequestParams): Promise
Parameters:
Name | Type |
---|---|
params | RequestParams |
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:
Name | Type |
---|---|
payload | UpdateSessionPayload |
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
1 year ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago