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
The
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
Use thesource property on a field to enable normalization with standard medical terminologies. The following values are supported:
| Value | System | Description |
|---|---|---|
"ICD10" | ICD-10 (International) | International Classification of Diseases, 10th revision |
"cie_latam" | CIE-10 (Latin America) | Latin American adaptation of ICD-10 |
Contact support@omniloy.com for additional coding system support (e.g., SNOMED CT, LOINC).
Specialized fields
Medical terminology sources
Use thesource property to enable normalization with standard terminologies:
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:
| Console message | Meaning | Action |
|---|---|---|
[Sofia SDK] Settings - Template loaded: {n} fields | Template was parsed successfully with n fields | None — this is the expected success message |
[Sofia SDK] Settings - Template validation failed | Template JSON is malformed or missing required schema keys | Check JSON syntax and ensure $schema, type, and properties are present |
[Sofia SDK] Settings - Using fallback template | Local template was invalid; SDK fell back to server-side template | Fix the local template prop — check for syntax errors or invalid field types |
[Sofia SDK] API - Report generation started | User clicked Generate; processing has begun | None — wait for completion or failure |
[Sofia SDK] API - Report generation completed | Report was generated and delivered to handleReport | Verify the data in your handleReport callback |
[Sofia SDK] API - Report generation failed: {error} | Report generation encountered an error | Check the error message for details (configError, authError, apiError, or settingsError) |
Common issues
Generate button doesn't appear
Generate button doesn't appear
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