getConfig

View as MarkdownOpen in Claude

Look up a configuration value by key, with an optional default. The config object is whatever was passed to the skill’s constructor (typed as SkillConfig, a string-keyed record). Values are returned as-is; the caller provides the type argument for casting.

Parameters

key
stringRequired

The configuration key to look up.

defaultValue
T | undefined

Value to return when the key is not present. The result is cast to T.

Returns

T — the configured value cast to the generic type, or the default value.

Example

1import { SkillBase } from '@signalwire/sdk';
2
3export class WeatherSkill extends SkillBase {
4 static SKILL_NAME = 'weather';
5 static SKILL_DESCRIPTION = 'Fetches current weather for a city.';
6
7 async setup(): Promise<boolean> {
8 const apiKey = this.getConfig<string>('api_key');
9 const units = this.getConfig<'metric' | 'imperial'>('units', 'metric');
10 if (!apiKey) return false;
11 this.logger.info(`Weather skill configured in ${units} units`);
12 return true;
13 }
14}