Skip to main content
Follow along with the runnable example. This guide walks through the Dictation commands example in corti-examples — bootstrap your build from it or use it as reference.
Commands let users drive your application by voice — delete a segment, insert a template, jump to a field, apply formatting. You declare command phrases in the dictation configuration; when the server recognizes one, it emits a command event (separate from transcript), and your client turns it into a real action.
For the command configuration schema (phrases, variables) see Commands, and for guidance on designing reliable command phrases see Commands Tips and Examples. This page focuses on wiring recognized commands to real editor actions.

The command loop

1

Declare commands

Add a commands array to your dictationConfig. Each command has an id, one or more phrases, and optional variables.
2

Receive the event

On a match, the Web Component emits a command event carrying the command id and any recognized variables.
3

Dispatch an action

Look up the command id in a registry and run its handler against your editor.

Declare commands

Phrases can be fixed, or include {variable} placeholders. A variable is either an enum (a fixed value list) or a wildcard (open-ended spoken text). Add a commands array to your dictationConfig — each entry needs an id, one or more phrases, and optional variables. See the commands example in corti-examples for the full configuration.
Give every command a unique id and non-overlapping phrases, and lead with an action verb ("go to...", "insert..."). See Commands Tips and Examples for the full checklist.

Handle the command event

Listen for the command event alongside transcript. The event data carries the matched id and a variables map keyed by your variable keys — pass both to your dispatch function.

Dispatch to editor actions

Keep commands data-driven: map each command id to a handler in a registry, and have every handler act through the same EditorAdapter used for text insertion — so the identical command logic works against a <textarea>, a contenteditable, or a native control.
JavaScript
Segment-relative commands like delete that need the range of each committed dictation segment. Track those ranges as you insert (see Text Insertion) and keep them valid as the user types — the example does this with an offset map.
For a user-manageable command set, represent each command’s behavior as data — e.g. insert_text (fixed text), keypress (a keystroke sequence), or a small script — rather than a hard-coded function. The example implements exactly these action kinds so users can create and edit their own commands.

Next steps

Commands

The full command configuration schema: phrases and variables.

Commands Tips and Examples

Designing reliable command phrases and handling detected commands.

App Control

Drive your application’s UI — tabs, panels, dialogs — by voice.

Example code

The complete, runnable Dictation commands example in corti-examples.
Please contact us for help or questions.