Configuration

View as MarkdownOpen in Claude

The SignalWire Agents SDK uses a layered configuration system. Settings can come from constructor parameters, environment variables, JSON config files, or sensible defaults. The layers are resolved in priority order:

  1. Constructor parameters — highest priority
  2. Environment variables — override config file values
  3. Config file values — loaded from JSON
  4. Defaults — built-in fallback values
1import { ConfigLoader } from '@signalwire/sdk';
2
3// Constructor parameters take precedence over everything else
4const config = new ConfigLoader('./my_config.json');
5const port = config.get<number>('server.port', 3000);

Config File Discovery

When no explicit config file path is provided, the SDK searches for JSON config files using ConfigLoader.search(), which checks these locations in order:

  1. Current working directory
  2. ./config/
  3. ~/.signalwire/

See ConfigLoader for the full file discovery logic and environment variable substitution syntax.

Key Configuration Areas

AreaConfigured ViaReference
Server port, host, routeConstructor, PORT env var, config fileEnvironment Variables
AuthenticationSWML_BASIC_AUTH_* env vars, config fileAuthHandler
CORS and host allowlistsSWML_CORS_ORIGINS, SWML_ALLOWED_HOSTS env varsEnvironment Variables
LoggingSIGNALWIRE_LOG_MODE, SIGNALWIRE_LOG_LEVEL env varsEnvironment Variables
RELAY / REST authSIGNALWIRE_PROJECT_ID, SIGNALWIRE_API_TOKEN, SIGNALWIRE_SPACEEnvironment Variables

Quick Example

1{
2 "service": {
3 "name": "support-agent",
4 "host": "0.0.0.0",
5 "port": 8080,
6 "route": "/support"
7 },
8 "security": {
9 "basic_auth": {
10 "username": "${AUTH_USER|support_agent}",
11 "password": "${AUTH_PASSWORD}"
12 }
13 },
14 "agent": {
15 "auto_answer": true,
16 "record_call": false
17 },
18 "skills": [
19 { "name": "datetime" },
20 {
21 "name": "native_vector_search",
22 "params": {
23 "index_file": "./support_docs.swsearch",
24 "tool_name": "search_support"
25 }
26 }
27 ]
28}