My App

POST /api/v1/system-variables

Dynamic variable resolution for chat and voice AI interactions

System Variables

Resolves all dynamic context variables needed for AI interactions — contact details, custom fields, custom values, assistant config, and timezone information.

Volume: ~549K runs/week | Auth: None (internal service call)

Request

POST /api/v1/system-variables
Content-Type: application/json

Body Parameters

FieldTypeRequiredDescription
assistant_idstringInternal assistant ID
location_idstringGHL location ID
contact_idstringGHL contact ID
directionstringinbound or outbound
tostringDestination phone number
fromstringSource phone number
channelstringCommunication channel (SMS, Voice, etc.)

Response

Success

Returns a flat object of resolved variables:

{
  "contact_name": "John Doe",
  "contact_email": "john@example.com",
  "contact_phone": "+15551234567",
  "contact_timezone": "America/Denver",
  "assistant_name": "Support Agent",
  "assistant_prompt": "You are a helpful assistant...",
  "location_timezone": "America/New_York",
  "direction": "inbound",
  "to": "+15559876543",
  "from": "+15551234567",
  "channel": "Voice",
  "custom_field_company": "Acme Corp",
  "custom_value_greeting": "Welcome to our service!"
}

Assistant Not Found

{ "error": "Assistant not found" }

SubAccount Not Found

{ "error": "Location not found" }

Test with cURL

curl -X POST http://localhost:3000/api/v1/system-variables \
  -H "Content-Type: application/json" \
  -d '{
    "assistant_id": "asst_123",
    "location_id": "loc_456",
    "contact_id": "contact_789",
    "direction": "inbound",
    "to": "+15559876543",
    "from": "+15551234567",
    "channel": "Voice"
  }'

Pipeline Flow

  1. Parallel fetch: SubAccount + Assistant (Prisma)
  2. Validate both exist
  3. Fetch GHL contact (using SubAccount access token)
  4. Parallel: GHL custom fields + custom values for location
  5. Build variable map: contact fields, assistant config, custom fields/values
  6. Return flat object

On this page