addPatternHint

View as MarkdownOpen in Claude

Add a hint with pattern matching and replacement. This allows you to intercept specific ASR output and rewrite it before it reaches the AI — useful for correcting consistent misrecognitions or normalizing variations.

Parameters

opts
objectRequired

Pattern hint configuration object with the following fields:

opts.hint
stringRequired

Descriptive label for the hint (surfaced to the ASR alongside the pattern).

opts.pattern
stringRequired

Regular expression pattern to match.

opts.replace
stringRequired

Replacement text to substitute when the pattern matches.

opts.ignoreCase
boolean

Whether to ignore case when matching the pattern.

Returns

AgentBase — Returns this for method chaining.

Example

1import { AgentBase } from '@signalwire/sdk';
2
3const agent = new AgentBase({ name: 'support', route: '/support' });
4agent.setPromptText('You are a helpful assistant.');
5// Correct common ASR misrecognition
6agent.addPatternHint({
7 hint: 'SignalWire brand name',
8 pattern: 'signal\\s*wire|signal\\s*wired',
9 replace: 'SignalWire',
10 ignoreCase: true,
11});
12await agent.serve();