Skip to content

🎨 Template Studio & Canonical AST Engine

4 min readUpdated: Nov 29, 2026
View as Markdown

The Template Studio in Ring2All DMS enables VoIP engineers to construct hardware configuration templates that dynamically adapt to any user, extension count, or network topology without duplicating static files.


In traditional provisioning systems, each phone model requires a separate, hardcoded template file. If a phone supports 12 lines, engineers write 12 duplicate account blocks (account.1.*, account.2.*, …, account.12.*). If a subscriber only has 1 extension, the phone boots with 11 empty accounts attempting registration or cluttering memory.

Ring2All DMS replaces this with a Canonical Abstract Syntax Tree (AST):

  1. Define Once: Write a single universal template containing dynamic loop structures.
  2. Dynamic Generation: When a phone boots, the Jinja2 synthesizer renders only the exact number of active accounts, line keys, and codecs assigned to that extension.
  3. Multi-Vendor Compilation: The same logical AST structure can compile to Yealink .cfg, Grandstream .xml, Poly .cfg, or Snom .htm.
flowchart TD
    AST["Canonical AST Template Definition<br/>(Dynamic Loops & Macro Variables)"]
    Subscriber["Subscriber Extension Data<br/>(Extensions: 101, 102 | Server: 10.9.0.10 | Codecs: Opus, G.722)"]
    
    Synthesizer["Jinja2 Synthesizer & AST Compiler"]
    
    AST --> Synthesizer
    Subscriber --> Synthesizer
    
    Synthesizer --> Out1["Yealink Output (y000000000000.cfg)<br/>account.1.enable = 1<br/>account.2.enable = 1"]
    Synthesizer --> Out2["Grandstream Output (cfg{mac}.xml)<br/>&lt;P271&gt;1&lt;/P271&gt;<br/>&lt;P47&gt;10.9.0.10&lt;/P47&gt;"]
    Synthesizer --> Out3["Poly Output ({mac}-reg.cfg)<br/>reg.1.address='101'<br/>reg.2.address='102'"]

Template Studio Workbench

Template Studio organizes hardware configuration into three synchronized functional tabs:

Browse vendor-specific template files and certified base definitions across all manufacturers. Models & Template Catalog Tab

2. Studio Compiler & Real-Time Synthesizer

Section titled “2. Studio Compiler & Real-Time Synthesizer”

Side-by-side IDE featuring live parameter interpolation, AST syntax checking, and multi-tenant loop expansions. Studio Compiler Tab

Interactive dictionary of all available variables, loop definitions, codec structures, and vendor code mappings. AST Macro Reference Tab


Account configuration is wrapped inside dynamic loop directives that expand according to the subscriber’s assigned SIP credentials:

#!version:1.0.0.1
## ==============================================================================
## Dynamic SIP Account Provisioning
## ==============================================================================
{{LOOP_ACCOUNTS_START}}
account.{{ACCOUNT_INDEX}}.enable = {{ACCOUNT_ENABLED}}
account.{{ACCOUNT_INDEX}}.label = {{ACCOUNT_LABEL}}
account.{{ACCOUNT_INDEX}}.display_name = {{ACCOUNT_DISPLAY_NAME}}
account.{{ACCOUNT_INDEX}}.auth_name = {{AUTH_USERNAME}}
account.{{ACCOUNT_INDEX}}.user_name = {{EXTENSION_NUMBER}}
account.{{ACCOUNT_INDEX}}.password = {{SIP_PASSWORD}}
account.{{ACCOUNT_INDEX}}.sip_server.1.address = {{SIP_SERVER_IP}}
account.{{ACCOUNT_INDEX}}.sip_server.1.port = {{SIP_SERVER_PORT}}
account.{{ACCOUNT_INDEX}}.sip_server.1.transport_type = {{SIP_TRANSPORT}}
account.{{ACCOUNT_INDEX}}.codec.opus.enable = 1
account.{{ACCOUNT_INDEX}}.codec.opus.priority = 1
account.{{ACCOUNT_INDEX}}.codec.g722.enable = 1
account.{{ACCOUNT_INDEX}}.codec.g722.priority = 2
account.{{ACCOUNT_INDEX}}.codec.pcmu.enable = 1
account.{{ACCOUNT_INDEX}}.codec.pcmu.priority = 3
{{LOOP_ACCOUNTS_END}}
Macro Variable Description Resolved Example
{{ACCOUNT_INDEX}} Sequential index of the account on the phone 1, 2, 3
{{ACCOUNT_ENABLED}} Binary indicator whether line is active 1 or 0
{{ACCOUNT_LABEL}} Friendly text displayed on phone LCD line key Sales (101)
{{EXTENSION_NUMBER}} SIP username / extension identifier 101
{{AUTH_USERNAME}} Digest authentication username ext_101_tenant4
{{SIP_PASSWORD}} Secure registration secret v9$Kx#7mQ9p!zL
{{SIP_SERVER_IP}} Outbound proxy or PBX domain pbx.carrier.com
{{SIP_SERVER_PORT}} Signaling port 5060 (UDP/TCP) or 5061 (TLS)
{{SIP_TRANSPORT}} Transport protocol indicator 0 (UDP), 1 (TCP), 2 (TLS)

🎛️ Programmable Line Keys & DSS Loops

Section titled “🎛️ Programmable Line Keys & DSS Loops”

For executive phones and attendant consoles with dozens of line keys, Template Studio provides dedicated loops for Busy Lamp Fields (BLF), Speed Dials, and Call Parks:

## ==============================================================================
## Programmable DSS Line Keys
## ==============================================================================
{{LOOP_LINEKEYS_START}}
linekey.{{KEY_INDEX}}.type = {{KEY_TYPE_CODE}}
linekey.{{KEY_INDEX}}.line = {{KEY_ACCOUNT_INDEX}}
linekey.{{KEY_INDEX}}.value = {{KEY_TARGET_VALUE}}
linekey.{{KEY_INDEX}}.label = {{KEY_DISPLAY_LABEL}}
linekey.{{KEY_INDEX}}.extension = {{KEY_PICKUP_CODE}}
{{LOOP_LINEKEYS_END}}

Supported Key Types automatically translate into the vendor’s internal numeric key type code:

  • Line Key: Registers standard call appearance for the account.
  • BLF (Busy Lamp Field): Real-time subscription to extension presence via SIP NOTIFY.
  • Speed Dial: One-touch dialer for external PSTN numbers or internal short codes.
  • Call Park: Monitors Valet Parking lots with one-touch orbit retrieval.
  • Intercom / Paging: Initiates two-way direct intercom or one-way public announcement.

Template Studio includes a real-time side-by-side simulator:

  1. Template Editor (Left Panel): Code editor with syntax highlighting, auto-completion of macro variables, and linting.
  2. Simulation Variables (Center Panel): Mock subscriber environment where engineers configure test parameters (e.g., 3 accounts, TLS transport, 8 BLF keys).
  3. Generated Configuration Output (Right Panel): Live output showing the exact character-for-character file that the phone will receive upon downloading over HTTPS.

User Role Operations in Template Studio
VoIP Hardware Architect Authors canonical templates, tests account loop expansions, and verifies manufacturer compatibility.
PBX Administrator Customizes corporate feature parameters (screensavers, corporate LDAP address books, NTP time zones).
Support Tech Simulates customer configuration files during troubleshooting to verify codec priority and SIP port assignments.