Skip to main content

Voicemails

A user's voicemail inbox: audio playback, transcriptions, AI summaries, and call-back and delete actions.

Usage​

TypeScript
import { Voicemails } from '@dialstack/sdk-react/voicemails';

function Inbox({ userId }: { userId: string }) {
return <Voicemails userId={userId} />;
}
User ID required

Set the user whose voicemails to show (the userId prop or setUserId()). Without it the component shows an error state.

The list loads 20 voicemails at a time, with a Load more button at the end. See Pagination.

Options​

These are specific to voicemails. The common options (locale, formatting, icons, layout variant, classes, load callbacks) apply too.

React propWeb Component methodTypeDefaultDescription
userIdsetUserId(userId)stringRequiredUser whose voicemails to show
displayOptionssetDisplayOptions(options)VoicemailDisplayOptions—Show or hide parts of the UI (see below)
behaviorOptionssetBehaviorOptions(options)VoicemailBehaviorOptions—Playback and interaction behavior (see below)
customRowRenderersetCustomRowRenderer(renderer)(voicemail) => string—Return your own HTML for each row
classessetClasses(classes)VoicemailsClasses—Extra CSS classes (see Styling)

VoicemailDisplayOptions​

OptionTypeDefaultDescription
showDurationbooleantrueVoicemail length
showTranscriptionbooleantrueTranscription, when available
showCallbackButtonbooleantrueCall back button
showDeleteButtonbooleantrueDelete button
showProgressBarbooleantruePlayback progress bar
showTimestampbooleantrueWhen the voicemail was received

VoicemailBehaviorOptions​

OptionTypeDefaultDescription
autoPlayOnExpandbooleantrueStart playback when a voicemail is opened
confirmBeforeDeletebooleantrueAsk for confirmation before deleting
markAsReadOnPlaybooleantrueMark as read when played
allowSeekingbooleantrueAllow seeking in the progress bar
TypeScript
<Voicemails
userId={userId}
displayOptions={{ showDeleteButton: false }}
behaviorOptions={{ autoPlayOnExpand: false }}
/>

Events​

React propWeb Component methodEventWhen
onVoicemailSelectsetOnVoicemailSelect(cb){ voicemailId }A voicemail is opened
onVoicemailPlaysetOnVoicemailPlay(cb){ voicemailId }Playback starts
onVoicemailPausesetOnVoicemailPause(cb){ voicemailId }Playback pauses
onVoicemailDeletesetOnVoicemailDelete(cb){ voicemailId }A voicemail has been deleted
onCallBacksetOnCallBack(cb){ phoneNumber }The call back button is clicked
onDeleteRequestsetOnDeleteRequest(cb)voicemailIdBefore deleting. Resolve true to delete, false to cancel

Use onDeleteRequest to show your own confirmation dialog, and set confirmBeforeDelete: false so the built-in one doesn't show too.

TypeScript
<Voicemails
userId={userId}
behaviorOptions={{ confirmBeforeDelete: false }}
onDeleteRequest={async (voicemailId) => showConfirmDialog('Delete this voicemail?')}
onCallBack={(event) => startCall(event.phoneNumber)}
onVoicemailPlay={(event) => analytics.track('voicemail_played', { id: event.voicemailId })}
/>

Custom row renderer​

The renderer receives { id, from_name, from_number, created_at, duration_seconds, is_read, transcription?, summary? } and returns an HTML string. Escape any value you interpolate: caller names and transcriptions come from the caller.

JavaScript
const escape = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);

const renderRow = (voicemail) => `
<div class="voicemail-row ${voicemail.is_read ? '' : 'unread'}">
<strong>${escape(voicemail.from_name || 'Unknown')}</strong>
<span>${escape(voicemail.from_number)}</span>
<span>${new Date(voicemail.created_at).toLocaleDateString()}</span>
${voicemail.transcription ? `<p>${escape(voicemail.transcription)}</p>` : ''}
</div>
`;

// React: <Voicemails userId={userId} customRowRenderer={renderRow} />
voicemails.setCustomRowRenderer(renderRow);

Styling​

classes adds your own CSS class names to parts of the component. For colors, fonts and spacing, see Theming.

KeyApplied to
loadingLoading state
errorError state
emptyThe "no voicemails" message
listList container
itemEach voicemail
itemExpandedThe open voicemail
itemUnreadAn unread voicemail
playerAudio player
actionsAction buttons
TypeScript
<Voicemails userId={userId} classes={{ itemUnread: 'border-l-4 border-blue-500' }} />

Accessibility​

The component has ARIA labels on every interactive element, keyboard navigation (Tab, Enter, Space), focus management when opening and closing a voicemail, screen reader announcements for state changes, and visible focus indicators.

Next steps​