Passing
templateSchema directly in startRecording is new in SDK v1.6.0. If you are on an earlier version, use the API approach described below.Two ways to use templates
You can provide a template to Squire either server-side via the API or client-side via the SDK.Choose your approach
Use the API approach if you manage templates centrally on your server and want to reuse them across multiple clients. Use the SDK approach if you need to define or update templates dynamically at the point of recording.
Create or pass the template
- Via API (server-side)
- Via SDK (client-side)
Create and store the template by posting to the Template API on your server. Once created, pass the returned template ID when starting a recording:
Receive structured output
Listen for the
summary-ready event and process the returned data using the Template utility class. See Processing results below.Template schema
A template schema is an object with afields array. Each field defines one piece of data Squire should extract from the consultation.
Field properties
| Property | Required | Description |
|---|---|---|
id | Yes | Unique identifier for the field (e.g., "symptoms_start"). |
name | Yes | Human-readable display name (e.g., "Onset Date"). |
valueType | Yes | Data type of the expected value. One of: text, options, date, boolean. |
valueOptions | For options type | Array of { value: string, description?: string } objects defining allowed choices. |
description | No | Additional context or unit information to improve extraction accuracy. |
fields | No | Array of nested fields. Use this when values are related to each other. |
Field types
| Type | Description |
|---|---|
text | Free text output. |
options | Fixed choices, as defined in valueOptions. |
date | Date value in YYYY-MM-DD format. |
boolean | true or false output. |
Schema example
Processing results
When thesummary-ready event fires, use the Template utility class to extract field values from the response without manually traversing the data structure.
Template utility methods
| Method | Description |
|---|---|
Squire.Template.fromResponse(response) | Creates a Template instance from the API response data. |
template.getFieldValues() | Returns a flat Record<id, value> map of all field IDs and their extracted values. |
template.getFieldById(id) | Searches for a specific field by ID, including fields nested inside other fields. |