UpdatedThe
useAmbientSession hook now returns a sessionType property. This helps you determine whether the session is an online or offline session.Quick summary
The
The hook provides methods to
useAmbientSession hook controls your audio recording workflow. Use it after creating a session with useAmbient to manage recording, pausing, and submitting audio.The hook provides methods to
start, pause, resume, cancel, and submit recordings. It returns session status so you can update your UI and provides real-time audio data through callbacks for building visualizations.useAmbientSession hook allows you to control the ambient recording workflow after you have an ambientSessionId. It exposes start, pause, resume, cancel, and submit, optional setSessionContext, session status, sessionType (online or offline), and optional real-time audio chunks for visualizations.
Configuration
Pass theambientSessionId you received from useAmbient after session.isSuccess is true (refer to Create Ambient Session). Run the hook under PlatformClientProvider.
Refer to Platform client and provider for more information.
Common use cases
Control the recording lifecycle
Use the recording control methods to match the behavior of your application’s recording experience:
start()to begin recordingpause()to temporarily stop audio captureresume()to continue a paused recordingcancel()to discard the current sessionsubmit()to finalize and submit the recording for processing
Attach clinical context to a session
Use
setSessionContext() to associate patient, provider, and visit metadata with the active session.Call setSessionContext() after start() and before submit() to ensure the metadata is included with the session. For supported fields and examples, refer to Session context below.Support online and offline session flows
Read
sessionType to determine how the session is running:"online"for real-time workflows"offline"for deferred or asynchronous processing workflows
Process audio waveform data
Use
onAudioChunkAvailable to receive streamed audio chunks during recording. Audio data is returned as batched Int16Array chunks.Optionally configure config.audioBatchSize to control the batch size and frequency of audio chunk delivery.Build responsive session status UI
Use the returned session state values to drive UI behavior throughout the recording workflow:
sessionStatusfor displaying the current session stateisFetchingfor loading indicators and disabled statesambientSessionIdfor identifying and tracking the active session
useAmbientSession hook
Usage
CalluseAmbientSession with an object that includes ambientSessionId and optional config and onAudioChunkAvailable.
Returns
The hook returns control methods, session status,sessionType, and related fields. Parameter and return shapes are documented under Configuration and What it returns.
How recording works
- Pass the session ID: Provide the
ambientSessionIdfromuseAmbient. - Configure options: Optionally set
config.audioBatchSizeandonAudioChunkAvailablefor real-time audio batches. - Use the controls: Call
start,pause,resume,cancel, andsubmitto move through the lifecycle your UI needs.
Configuration
Configure the hook with these parameters:Pass the unique session identifier you received from the
useAmbient hook. This links the recording to the session you created.Optional: Configure the audio batch size for the
onAudioChunkAvailable callback.Optional: Provide a callback function that receives audio chunks as they become available. The SDK calls this function whenever a batch of audio data is ready. Use this to draw real-time waveforms, visualizers, or other audio visualizations in your UI.
What it returns
The hook returns control methods and status information you use to manage recording and update your UI.Actions (methods)
Use these methods to control the recording workflow:Call this to begin recording audio. Call this when the user clicks a “Start Recording” button.
Call this to pause recording temporarily. Resume later with
resume(). Call this when the user clicks a “Pause” button.Call this to resume a paused recording. Call this when the user clicks a “Resume” button.
Call this to stop recording and cancel the session. Call this when the user clicks a “Cancel” or “Discard” button.
Call this to finish recording and submit the session for note generation. Call this when the user clicks a “Finish” or “Submit” button.
Call this to send patient, provider, and visit metadata to Suki. The function sends context information that helps Suki generate more accurate clinical notes. Call this after
start() but before submit() for best results.State (data)
Use these values to control your UI and show the current session state:Check this value to display the current session state in your UI. Common values:
"created" (session ready to start), "submitted" (recording finished, processing), "completed" (note generated), and "cancelled" (session cancelled). Use this to show status messages, enable/disable buttons, or change UI states based on the session status.Check this flag to show a loading state while syncing session information. When
true, the SDK is currently fetching session status from Suki’s backend. Display a loading indicator or disable actions while this is true.Use this value to determine whether the session is an online or offline session.
Session context
ThesetSessionContext method lets you send patient, provider, and visit information to Suki. This context helps Suki’s AI generate more accurate and relevant clinical notes.
What is session context?
Session context is metadata about the patient visit that improves note quality. Include:- Patient details: Date of birth, sex
- Provider information: Specialty, role
- Visit information: Visit type, encounter type, reason for visit, chief complaint
- Clinical sections: LOINC codes for specific sections you want in the note
- Diagnoses: Pre-existing or current diagnoses with codes and descriptions
When to use it
CallsetSessionContext after calling start() but before calling submit(). Providing context early helps the AI understand the clinical scenario and generate better notes.
Session context structure
Response type
setSessionContext method returns an empty object when successful. If an error occurs, it throws a ContextUpdateFailed error. See the Error handling guide for details.
Code example
This example shows how to build a recording interface with Start, Pause, Resume, and Submit controls. The UI updates based onsessionStatus to show the appropriate buttons at each stage.
React