template property defines the structure of clinical data that SofIA should generate. It must be a complete JSON Schema Draft-07 schema that specifies the fields, types, and validations required for medical documentation.
The
template prop accepts a JSON Schema defining the report structure. Throughout this page, “template” refers to the prop and “schema” refers to the JSON Schema content.Accessibility (a11y)
If your integration sends a configuration payload (usingtemplate or legacy toolsargs), you can add an accessibility variable at the same level to define visual preferences.
Use the property names exactly as shown below (language-agnostic payload keys). For consistency, each option value is an array of accepted labels/aliases.
Recommended technical term:
Accessibility (a11y). The number 11 represents the letters between a and y.How Templates Work
1
Input
The JSON Schema template and conversation context are provided to the SofIA SDK.
2
AI Processing
The SDK sends the data via LangGraph Streaming for AI processing.
3
Structured Output
The AI generates a structured report matching the schema, delivered to the EHR/HIS via the
handle-report callback.template defines what data to extract. SofIA’s AI reads the conversation context and fills the schema fields automatically, delivering a structured JSON report that matches your schema.
Required structure
The schema must include:- $schema: Reference to the JSON Schema Draft-07 standard
- title: Identifier of the clinical document type
- type: Must be “object” for structured documents
- required: Array with mandatory fields
- properties: Detailed definition of each field
Basic example
Passing templates to the component
As an HTML attribute — wrap the JSON in single quotes, use double quotes inside:Clinical coding sources
There are two ways to get standardized clinical codes into a field:- Set the field’s
sourceto a master. A master is a controlled terminology or code catalog that Omniloy maintains for your account. Thesourcevalue links the field to that master, so SofIA normalizes the extracted value against it. Need coding against your own data — a custom catalog, an internal code set, or a specialty terminology? Contact support@omniloy.com: the Omniloy team provisions the custom master for your account and gives you thesourcevalue to use. A customsourceonly works once its master has been created for your account. - Ask for the terminology in the field
description— e.g."Primary diagnosis with its ICD-10 code". SofIA’s agents apply the requested coding during extraction even without asource. This is handy for one-off coding requests where a dedicated master isn’t needed.
Specialized fields
Medical terminology sources
Point a field at a custom master withsource (provisioned by Omniloy — see Clinical coding sources). You can also drive the coding from each field’s description, as shown below. Replace "your-custom-master" with the source value Omniloy gives you:
Structured vital signs
Supported data types
Basic types
- string: Free or controlled text
- number: Numeric values (integers or decimals)
- boolean: True/false values
- array: Lists of elements
- object: Complex nested structures
Advanced validations
Technical limitations
- Maximum size: 100 KB per schema
- Depth: Maximum 10 nesting levels
- Complexity: Avoid overly complex schemas that may affect performance
Best practices
Detailed descriptions
Provide clear and specific descriptions for each field:Appropriate validations
Implement validations that reflect clinical reality:Flexible structures
Design schemas that allow for clinical variability:Property Customization
The isConfigurable property
Default value: true (all fields are configurable by default)
When isConfigurable is true (default), the healthcare professional can edit the generated field value in the SofIA interface before finalizing the report. Set to false for fields that should be generated but not editable.
Configurable field (default behavior):
Debugging your template
Enable debug mode
Adddebug="true" to the SofIA component to enable detailed console logging. All SDK logs are prefixed with [Sofia SDK], making them easy to filter in browser DevTools.
Template validation checklist
Before debugging in the browser, verify these five points:- Valid JSON Schema — includes
"$schema": "http://json-schema.org/draft-07/schema#"header - Both
templateandtemplateidare present — the generate button only appears when both are provided propertiesdefined with at least 1 field — an emptypropertiesobject results in chat-only mode- Schema size under 100KB — larger schemas are rejected
requiredfields match existing properties — any mismatch causes validation errors
Console log reference
Whendebug="true" is enabled, these are the key messages related to templates and report generation:
Common issues
handleReport returns an empty object
handleReport returns an empty object
Symptom: The
handleReport callback fires but the report object is {} or contains only empty values.Cause: The template fields don’t match the conversation context. SofIA extracts data based on what was discussed — if the conversation doesn’t contain information relevant to your template fields, those fields will be empty.Solution:- Ensure the conversation covers topics related to your template fields before clicking Generate
- Check that field
descriptionvalues are clear and specific — vague descriptions lead to poor extraction - Enable
debug="true"and verifyReport generation completedappears (notfailed)
handleReport returns partial data
handleReport returns partial data
Symptom: Some fields in the report are populated but others are missing or null.Cause: The AI could only extract data for fields that were discussed in the conversation. Fields marked as
required in your schema are prioritized, but optional fields may be omitted if the conversation doesn’t contain relevant information.Solution:- Review which fields are missing — do they correspond to topics discussed in the conversation?
- Add more specific
descriptionvalues to help the AI identify relevant information - Consider marking critical fields as
requiredin your schema
Template falls back to server defaults
Template falls back to server defaults
Symptom: The generated report uses a different structure than your local template. In debug mode, you see
Using fallback template.Cause: The SDK couldn’t parse your local template prop. It attempts three parsing strategies (JSON.parse, prefix removal, Function eval) — if all fail, it falls back to the server-configured template for your templateid.Solution:- Validate your template JSON at jsonlint.com
- Ensure the template is passed as a valid JSON string, not a JavaScript object
- Check for special characters or encoding issues in the template string
- In debug mode, look for
Template validation failedfor specific error details