Integrate with voice data - Agent Workspace

Integrate with voice data

Instantiating the voice client

You can instantiate the voice client as follows:

import { VoiceClient } from "@amazon-connect/voice"; const voiceClient = new VoiceClient();

For the zero-arg constructor demonstrated above to work correctly, you must first instantiate the app which will set up the default AmazonConnectProvider. This is the recommended option.

Alternatively, see the API reference to customize your client’s configuration. Once the voice client is instantiated, you can use it to make requests.

Example voice request

The following voice event and request are non-exhaustive. For a full list of available voice events and requests, see the API reference.

import { VoiceClient } from "@amazon-connect/voice"; import { AppContactScope } from "@amazon-connect/app"; const voiceClient = new VoiceClient(); const phoneNumber = await voiceClient.getPhoneNumber(AppContactScope.CurrentContactId); console.log(`Got the phone number: ${phoneNumber}`);