setPromptText

View as MarkdownOpen in Claude

Set the agent’s system prompt as a raw text string. This is the simplest way to configure what the AI knows and how it behaves.

This sets the SWML ai.prompt field. See the SWML prompt reference for details on prompt behavior.

Mixing raw text prompts with POM-based prompt sections (promptAddSection()) in the same agent may produce unexpected results. Use one approach or the other for the main prompt. Contexts can still be used alongside either approach.

Parameters

text
stringRequired

The complete system prompt text. Supports multi-line strings.

Returns

AgentBase — Returns this for method chaining.

Example

1import { AgentBase } from '@signalwire/sdk';
2
3const agent = new AgentBase({ name: 'support', route: '/support' });
4agent.setPromptText(`
5You are a customer support agent for Acme Corp.
6You help customers with billing questions, order tracking, and returns.
7Always be polite and professional.
8`);
9await agent.serve();