For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • Configuration
      • ContextBuilder
        • addContext
        • Context
          • addBullets
          • addEnterFiller
          • addExitFiller
          • addSection
          • addStep
          • addSystemBullets
          • addSystemSection
          • getStep
          • moveStep
          • removeStep
          • setConsolidate
          • setEnterFillers
          • setExitFillers
          • setFullReset
          • setInitialStep
          • setIsolated
          • setPostPrompt
          • setPrompt
          • setSystemPrompt
          • setUserPrompt
          • setValidContexts
          • setValidSteps
        • createSimpleContext
        • GatherInfo & GatherQuestion
        • getCompletionAction
        • getContext
        • getGatherInfo
        • getQuestions
        • getStepOrder
        • getSteps
        • getValidContexts
        • reset
        • Step
        • toDict
        • validate
      • DataMap
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • ChatResource
      • Compat
      • Datasphere
      • Fabric
      • ImportedNumbersResource
      • Logs
      • LookupResource
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSubResource
      • Queues
      • Recordings
      • Registry
      • RestClient
      • RestError
      • Short Codes
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Properties
  • Methods
  • Example
AgentsContextBuilder

Context

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

addBullets

Next
Built with

A Context represents a distinct conversation mode — like “sales”, “support”, or “billing” — within a ContextBuilder. Each context holds an ordered sequence of Step objects and configures its own prompt, system prompt, fillers, and navigation rules.

You obtain a Context by calling addContext() on a ContextBuilder or by calling getContext() to retrieve one that already exists.

Properties

name
stringRequired

Unique context name. When using a single context inside a ContextBuilder, this must be "default".

Methods

addBullets

Add a POM section with bullet points to the context prompt.

addEnterFiller

Add enter fillers for a specific language.

addExitFiller

Add exit fillers for a specific language.

addSection

Add a POM section to the context prompt.

addStep

Add a new step to this context.

addSystemBullets

Add a POM section with bullets to the system prompt.

addSystemSection

Add a POM section to the system prompt.

getStep

Get an existing step by name.

moveStep

Move an existing step to a specific position in the step order.

removeStep

Remove a step from this context.

setConsolidate

Set whether to consolidate conversation history when entering this context.

setEnterFillers

Set all enter fillers at once.

setExitFillers

Set all exit fillers at once.

setFullReset

Set whether to fully reset conversation history when entering this context.

setInitialStep

Set which step the context starts on when entered.

setIsolated

Set whether to truncate conversation history when entering this context.

setPostPrompt

Override the post-prompt text while this context is active.

setPrompt

Set the context’s prompt text directly.

setSystemPrompt

Set a new system prompt that takes effect when this context is entered.

setUserPrompt

Inject a user message when entering this context.

setValidContexts

Set which contexts the agent can navigate to from this context.

setValidSteps

Set which steps can be navigated to from any step in this context.

Example

1import { ContextBuilder } from '@signalwire/sdk';
2
3const builder = new ContextBuilder();
4const main = builder.addContext('default');
5main.addStep('menu').setText('Ask whether the caller needs sales or support.');
6
7const support = builder.addContext('support');
8
9// System prompt for this context
10support.setSystemPrompt('You are a patient technical support engineer.');
11support.setConsolidate(true);
12
13// Fillers for smooth transitions
14support.addEnterFiller('en-US', [
15 'Let me connect you with support...',
16 'Transferring you now...',
17]);
18support.addExitFiller('en-US', [
19 'Thank you for contacting support.',
20 'Glad I could help.',
21]);
22
23// Navigation
24support.setValidContexts(['default']);
25
26// Steps
27support.addStep('diagnose', {
28 task: 'Understand the customer\'s issue and gather relevant details.',
29 criteria: 'Issue is clearly identified',
30 functions: ['lookup_account', 'check_status'],
31 validSteps: ['resolve'],
32});
33support.addStep('resolve', {
34 task: 'Resolve the issue or escalate to a specialist.',
35 functions: ['create_ticket', 'transfer_call'],
36 validSteps: ['farewell'],
37});
38support.addStep('farewell')
39 .setText('Thank the caller and end the conversation.')
40 .setFunctions('none')
41 .setEnd(true);