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.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
Declare commands
Add a
commands array to your dictationConfig. Each command has an id, one or more phrases, and optional variables.Receive the event
On a match, the Web Component emits a
command event carrying the command id and any recognized variables.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.
Handle the command event
Listen for thecommand 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 commandid 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.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.