Skip to content

Voicemail

Parimala032 edited this page Aug 6, 2024 · 7 revisions

Caution

This documentation may no longer be current. Click here to view the updated content on our Developer Portal.

Webex Calling Web SDK 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.

Initialize the voicemailClient

The 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();

Voicemail Response Object

Here'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

Name Description Values Required
sort Sorting order of voicemail list, ASC or DESC.

String

ASC DESC
yes
offset Number of records to skip.

Number

yes
offsetLimit Index of the voicemail to fetch from the voicemail list. String yes
refresh Refresh the list of voicemails from the backend. Boolean yes
Parameters See table above
Returns Promise<VoicemailResponseEvent>

Fetch a Voicemail Summary

The 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,
};

Fetch a Voicemail Transcription

The 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,
};

Mark a Voicemail As Unread

The 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,
};

Delete a Voicemail

The 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,
};
Clone this wiki locally