# Commands

Commands are methods of the [client](/connect/sdk/reference/type-aliases/NablaConnectClient.md). Each one returns a promise.

## Available commands[​](#available-commands "Direct link to Available commands")

| Method                  | Requires `availableActions` | Effect                                                                                                               |
| ----------------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `startRecording()`      | `START_RECORDING`           | Start, or resume from `PAUSED` or `NOTE_READY`.                                                                      |
| `stopRecording()`       | `STOP_RECORDING`            | Same as Pause in the Nabla UI. Accepted without effect when nothing is recording, so repeating it is safe.           |
| `startNoteGeneration()` | `GENERATE_NOTE`             | Stop the recording if needed, then generate the note. From `NOTE_READY`, regenerates it.                             |
| `exportNote()`          | `EXPORT_NOTE`               | Same as the Export button: the [`noteExported`](/connect/guides/sdk/exports.md) event plus your configured callback. |

Offer a command only when the iframe lists it in [`availableActions`](/connect/guides/sdk/encounter-state.md#available-actions).

## When a command resolves[​](#when-a-command-resolves "Direct link to When a command resolves")

A command resolves once the iframe has run it: the recording has started or paused, the note was exported, or the note generation has started. A generation ends on `stateChanged`, with `NOTE_READY` or with `reason` set to `NOTE_GENERATION_FAILED`.

No `stateChanged` arrives while a command runs, or while nothing changes. The new state follows right after the command resolves, so do not take the silence for a crash.

## One command at a time[​](#one-command-at-a-time "Direct link to One command at a time")

A second call while one is pending rejects with [`BUSY`](/connect/guides/sdk/errors.md#busy). Wait for the first one to settle.

## Timeouts[​](#timeouts "Direct link to Timeouts")

A command that gets no answer within 30 seconds rejects with [`TIMEOUT`](/connect/guides/sdk/errors.md#timeout) and the `reason` `NO_RESULT`. This does not mean the command failed: it can still succeed.

A command can take longer when the user is slow to allow the microphone, or when audio is still uploading. Read `stateChanged` or `getCurrentState()` to learn the outcome.

## Before `ready`[​](#before-ready "Direct link to before-ready")

A command called before `ready` waits for it. If `ready` rejects, the command rejects with the same error.

## `waitUntilClosable()`[​](#waituntilclosable "Direct link to waituntilclosable")

`waitUntilClosable()` is not a command. It resolves once `state.canBeClosed` is `true`, immediately if it already is, so you can wait before you call `destroy()` or tear down the page. It has no timeout, and rejects with `DESTROYED` or `CONTEXT_CHANGED`. See [Leave and switch encounters](/connect/guides/sdk/leave-and-switch.md).
