await dictationClient.show({ ... }) from your own code when the user is ready.
Let’s get started!
Prerequisites
Before you begin, you must have the following requirements met:- Packages: Install
@suki-sdk/dictationand@suki-sdk/corepackages. - Partner credentials: Obtain
partnerIdandpartnerTokenfrom Suki after Partner onboarding. - Browser and layout: Your app runs in a browser, with a real DOM and a dictation container that has height.
Install the packages
Add both packages to the same project you load in the browser:Step 1: Add container and field HTML
For this example we will assume you are usingin-field mode as your preferred mode.
In in-field mode you need two nodes in the page: a div (or similar) that you pass as rootElement, where the dictation controls show up, and a textarea (or input) that onSubmit will update when the user finishes.
The dictation layer matches the size of rootElement, so that node should have a height you control. Refer to Wrapper layout guide for recommended markup and CSS.
HTML
Step 2: Create auth manager
Now you need to create the Auth Manager for your application. To create the Auth Manager, you must have thepartnerId and partnerToken credentials from Suki.
Refer to Partner onboarding guide to learn how to get these credentials.
Once you have all the required credentials, create one auth manager for the page (or app shell).
Code example for creating auth manager
JavaScript
Step 3: Create dictation client
After you have created the auth manager, you can create the dictation client for your application. The Dictation Client is the object that will be used to start the dictation session. Create one dictation client and reuse it for everyshow() call on that page.
Code example for creating dictation client
JavaScript
Step 4: Call show() to start dictation
Now you can start the dictation session by calling theshow() method on the dictation client.
Call await dictationClient.show({ ... }) from a click handler (or similar) when the DOM is ready.
Pass mode, fieldId, rootElement, onSubmit, and any optional fields you need. Refer to Configuration guide for more details on the available options and how to use them.
Code example for starting dictation
JavaScript
onSubmit is required for a good user experience. If you omit it, dictation often closes immediately after the user acts.Callbacks
Every callback receives the same shape as shown in the code example below:JavaScript
Switching fields
Callingshow() again replaces the active session. You do not need to call hide() manually just to move from one field to another:
JavaScript
Complete code example
Below is a complete code example in JavaScript for in-field mode with a single field.JavaScript