---
schema_version: "1"
id: 0bce13cefdfd494459e29658816c84ffc6713a725d30a1bfedee222ac566c1e1
title: Service Cloud Voice Toolkit API
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lightning-base-components/lightning-design-system/guides/lwc/components/lightning/serviceCloudVoiceToolkitApi/lightning-service-cloud-voice-toolkit-api.md
canonical_url: https://developer.salesforce.com/docs/platform/lightning-component-reference/guide/lightning-service-cloud-voice-toolkit-api.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 07614e19dd9bf20f0327edba8aee0b061db0dd62c264b963452b977150783e10
products:
  - Lightning Component Reference
---
# Service Cloud Voice Toolkit API

**`lightning-service-cloud-voice-toolkit-api`**

A collection of front-end event listeners and API methods for interacting with Service Cloud Voice using the `lightning-service-cloud-voice-toolkit-api` component. This component requires API version 52.0 and later.

**For Use In**

Lightning Experience

::::::tabset{tabs='[ "Develop", "Specifications"]'}

:::::tab

Service Cloud Voice Toolkit API is a collection of front-end event listeners and API methods for interacting with the Service Cloud Voice product. This toolkit takes advantage of Einstein Next Best Action to give agents what they need when they need it during a conversation.

To use the Service Cloud Voice Toolkit API in your component:

- Add the `lightning-service-cloud-voice-toolkit-api` component to your component's HTML template file.

<!-- prettier-ignore-start -->
```html
<!-- yourComponent.html -->

<template>
    <lightning-service-cloud-voice-toolkit-api>
    </lightning-service-cloud-voice-toolkit-api>
    ...
</template>
```
<!-- prettier-ignore-end -->

- Include the `lightning__ServiceCloudVoiceToolkitApi` capability in your component’s configuration file, `<component>.js-meta.xml`.

```xml
// yourComponent.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
  <apiVersion>52.0</apiVersion>
  <isExposed>true</isExposed>
  <capabilities>
    <capability>lightning__ServiceCloudVoiceToolkitApi</capability>
  </capabilities>
</LightningComponentBundle>
```

For more information about configuration files, see [XML Configuration File Elements](https://developer.salesforce.com/docs/platform/lwc/guide/reference-configuration-tags).

## Service Cloud Voice Events

Make your components context-aware by listening to events that take place during phone calls.

To subscribe to an event, add an event listener. For instance, the following code subscribes and unsubscribes to the `callstarted` event type.

```javascript
// Subscribe
const toolkitApi = this.template.querySelector('lightning-service-cloud-voice-toolkit-api');
toolkitApi.addEventListener('callstarted', <listener>);

// Unsubscribe
const toolkitApi = this.template.querySelector('lightning-service-cloud-voice-toolkit-api');
toolkitApi.removeEventListener('callstarted', <listener>);
```

When an event occurs, your listener function receives a JSON payload that contains the event type, along with any relevant data. For instance, the `callstarted` event contains the following payload.

```
{
  "type":  "callstarted",
  "detail":  {
    "callId":  "d7a9f1b7-fc17-43fe-8ca7-e584a2b34792",
    "callType":  "outbound",
    "participant":  "+1 (415) 999-0000"
  }
}
```

For information about the available events, see [Service Cloud Voice LWC Toolkit API Events](https://developer.salesforce.com/docs/atlas.en-us.voice_developer_guide.meta/voice_developer_guide/voice_lc_toolkit_telephony_lwc.htm).

## Next Best Action

The toolkit provides the `updateNextBestActions` method, which enables your component to give recommendations in real time with Next Best Action.

For more information, see [Service Cloud Voice LWC Toolkit Next Best Action](https://developer.salesforce.com/docs/atlas.en-us.voice_developer_guide.meta/voice_developer_guide/voice_lc_toolkit_nba_lwc.htm).

## See Also

- [Service Cloud Voice ToolkitAPI Sample LWC Component](https://github.com/service-cloud-voice/examples-from-doc/tree/main/ToolkitAPI/SampleLWCComponent)
- [Toolkit API example](https://github.com/service-cloud-voice/examples-from-doc/tree/main/ToolkitAPI)


:::::

:::::tab
::component-specification{component="serviceCloudVoiceToolkitApi" model="lwc" namespace="lightning"}

:::::

::::::
