ai

View as MarkdownOpen in Claude

Add an ai verb to the main section. Starts an AI-powered conversation on the call.

This is a dynamic verb method that accepts a generic config object. The config is passed directly as the AI verb’s configuration payload in the SWML document.

Parameters

config
Record<string, unknown> | undefined

Optional configuration object for the AI verb. The structure matches the SWML AI verb specification and may include keys such as prompt, post_prompt, post_prompt_url, swaig, hints, languages, params, and global_data.

The prompt key accepts either a text string or a POM (Prompt Object Model) structure — these are mutually exclusive. Do not set both prompt.text and prompt.pom in the same config.

Returns

this — The builder instance for method chaining.

Example

1import { SwmlBuilder } from '@signalwire/sdk';
2
3const builder = new SwmlBuilder();
4builder.answer();
5builder.ai({
6 prompt: { text: 'You are a helpful assistant.' },
7 post_prompt_url: 'https://example.com/summary',
8});
9
10console.log(builder.renderDocument());