Voicemail
The VoicemailClient
object is a supplementary Calling SDK module that adds comprehensive support for voicemail functionality. Before continuing, refer to the Quickstart Guide to understand how Call
objects are created and how different modules are instantiated. The VoicemailClient
object offers a variety of functions which are covered in this article in detail.
anchorInitialize the voicemailClient
anchorThe voicemail client instance must be initialized to enable access to the voicemail backend services using the init()
methood of the voicemailClient
object:
const voicemailClient = calling.voicemailClient;
const initResponse = await voicemailClient.init();
anchorVoicemail Response Object
anchorHere's an example response from the voicemailClient method:
{
statusCode: number;
data: {
voicemailList?: MessageInfo[];
voicemailContent?: {
type: string | null;
content: string | null;
};
voicemailSummary?: SummaryInfo;
voicemailTranscript?: string | null;
error?: string;
};
message: string | null;
};
Fetch a Voicemail List
The getVoicemailList()
method retrieves the voicemails present in the voicemail box of the user:
const voicemailListResponse = await voicemailClient.getVoicemailList(
OFFSET,
OFFSETLIMIT,
SORT.DESC,
true
);
The following table describes the options available for the arguments passed to the getVoicemailList()
method:
Parameters | Options
|
Parameters | See table above |
Returns | Promise<VoicemailResponseEvent> |
anchorFetch a Voicemail Summary
anchorThe getVoicemailSummary()
method fetches the count for various categories of voicemails in a user's mailbox. The method's response consists of counts for new voicemails received, new urgent voicemails received, old voicemails, and old urgent voicemails:
const voicemailSummaryResponse = await voicemailClient.getVoicemailSummary();
Parameters | -- |
Returns | Promise<VoicemailResponseEvent> |
Here's an example of the response for the getVoicemailSummary()
method:
{
statusCode: 200,
data: {
voicemailSummary: {
newMessages: 2,
newUrgentMessages: 1,
oldMessages: 3,
oldUrgentMessages: 2,
},
},
message: SUCCESS,
};
anchorFetch a Voicemail Transcription
anchorThe getVMTranscript()
method API fetches a transcript for a voicemail. It takes a messageID
as an argument:
const voicemailTranscriptResponse = await voicemailClient.getVMTranscript(messageID);
Parameters | messageID<string> |
Returns | Promise<VoicemailResponseEvent> |
Here's an example of the response received when a transcript is fetched successfully:
{
statusCode: 200,
data: {
transcript: "This is some transcript text from the voicemail ID.",
},
message: READY | FAILURE | NA | PENDING,
};
The transcript object populates the string only when the transcription is complete and READY
. FAILURE
indicates that the voicemail service was unable to transcribe the voicemail, while PENDING
indicates that transcription is in progress. NA
indicates that transcription is not enabled for the user's voicemails.
Here's an example of a messageID
returned by the voicemail client:
v2.0/user/69fde5ad-fb8b-4a1b-9998-b0999e95719b/VoiceMessagingMessages/dfe55899-1f55-474f-8f00-bc5915757070
The entire string is used as the ID.
Mark a Voicemail As Read
The voicemailMarkAsRead()
method API marks a voicemail as read. It takes a messageID
as an argument:
const voicemailMarkAsReadResponse = await voicemailClient.voicemailMarkAsRead(messageID);
Parameters | messageID<string> |
Returns | Promise<VoicemailResponseEvent> |
Here's an example response from the voicemailMarkAsRead()
method:
{
statusCode: 200,
data: {},
message: SUCCESS,
};
anchorMark a Voicemail As Unread
anchorThe voicemailMarkAsUnread()
method API marks a voicemail as unread. It takes a messageID
as an argument:
const voicemailMarkAsUnreadResponse =
await voicemailClient.voicemailMarkAsUnread(messageID);
Parameters | messageID<string> |
Returns | Promise<VoicemailResponseEvent> |
Here's an example response from the voicemailMarkAsUnread()
method:
{
statusCode: 200,
data: {},
message: SUCCESS,
};
anchorDelete a Voicemail
anchorThe deleteVoicemail()
deletes a voicemail. It takes a messageID
as an argument:
const voicemailDeleteResponse = await voicemailClient.deleteVoicemail(messageID);
Parameters | messageID<string> |
Returns | Promise<VoicemailResponseEvent> |
Here's an example response from the deleteVoicemail()
method upon successfully deleting a voicemail:
{
statusCode: 200,
data: {},
message: SUCCESS,
};