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.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 pattern: 'signal\\s*wire|signal\\s*wired',
8 replace: 'SignalWire',
9 ignoreCase: true,
10});
11await agent.serve();