addSwaigQueryParams

View as MarkdownOpen in Claude

Add query parameters that will be included in all SWAIG webhook URLs generated by this agent. This is particularly useful for preserving dynamic configuration state across SWAIG callbacks — for example, passing a tenant identifier or feature tier so the same configuration is applied when SignalWire invokes tool webhooks.

Parameters

params
Record<string, string>Required

Object of query parameters to merge into every SWAIG URL. Subsequent calls merge into (not replace) the existing set. Pass the same key again to overwrite its value.

Returns

AgentBase — Returns this for method chaining.

Example

1import { AgentBase } from '@signalwire/sdk';
2
3const agent = new AgentBase({ name: 'assistant', route: '/assistant' });
4agent.setPromptText('You are a helpful assistant.');
5
6agent.setDynamicConfigCallback(async (queryParams, bodyParams, headers, agentCopy) => {
7 const tier = queryParams.tier ?? 'free';
8 if (tier === 'premium') {
9 agentCopy.setParams({ end_of_speech_timeout: 500 });
10 }
11 agentCopy.addSwaigQueryParams({ tier });
12});
13
14await agent.serve();