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
      • DataMap
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
    • RELAY
      • Overview
      • Actions
      • Call
        • ai
        • aiHold
        • aiMessage
        • aiUnhold
        • amazonBedrock
        • answer
        • bindDigit
        • clearDigitBindings
        • collect
        • connect
        • denoise
        • denoiseStop
        • detect
        • disconnect
        • echo
        • hangup
        • hold
        • joinConference
        • joinRoom
        • leaveConference
        • leaveRoom
        • liveTranscribe
        • liveTranslate
        • on
        • pass
        • pay
        • play
        • playAndCollect
        • queueEnter
        • queueLeave
        • receiveFax
        • record
        • refer
        • sendDigits
        • sendFax
        • stream
        • tap
        • transfer
        • unhold
        • userEvent
        • waitFor
        • waitForEnded
      • 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
  • Parameters
  • Returns
  • Example
RELAYCall

aiMessage

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

aiUnhold

Next
Built with

Send a message to an active AI agent session on the call. Use this to inject context, instructions, or simulated user input into a running AI conversation.

This method requires an active AI session started via ai(). Calling it without an active session has no effect.

Parameters

messageText
string | undefined

The message text to send to the AI agent.

role
string | undefined

The role of the message sender. Valid values:

  • "user" — simulate user input
  • "system" — send a system-level instruction
  • "assistant" — inject an assistant response
reset
Record<string, unknown> | undefined

Reset configuration. Allows resetting AI state such as the conversation history or functions.

globalData
Record<string, unknown> | undefined

Update the global data accessible to the AI and SWAIG functions.

Returns

Promise<Record<string, unknown>> — Server response confirming the message was sent.

Example

1import { RelayClient } from '@signalwire/sdk';
2
3const client = new RelayClient({
4 project: process.env.SIGNALWIRE_PROJECT_ID!,
5 token: process.env.SIGNALWIRE_API_TOKEN!,
6 contexts: ['default']
7});
8
9client.onCall(async (call) => {
10 await call.answer();
11
12 // Start an AI agent
13 const action = await call.ai({
14 prompt: { text: 'You are a helpful assistant.' },
15 });
16
17 // Inject a system message after 10 seconds
18 await new Promise((resolve) => setTimeout(resolve, 10_000));
19 await call.aiMessage({
20 messageText: 'The caller is a VIP customer. Be extra helpful.',
21 role: 'system',
22 });
23
24 await action.wait();
25});
26
27await client.run();