***

title: aiMessage
slug: /reference/typescript/relay/call/ai-message
description: Send a message to an active AI agent session.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[ai]: /docs/server-sdks/reference/typescript/relay/call/ai

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.

<Note>
  This method requires an active AI session started via
  [`ai()`][ai]. Calling it without
  an active session has no effect.
</Note>

## **Parameters**

<ParamField path="messageText" type="string | undefined" toc={true}>
  The message text to send to the AI agent.
</ParamField>

<ParamField path="role" type="string | undefined" toc={true}>
  The role of the message sender. Valid values:

  * `"user"` -- simulate user input
  * `"system"` -- send a system-level instruction
  * `"assistant"` -- inject an assistant response
</ParamField>

<ParamField path="reset" type="Record<string, unknown> | undefined" toc={true}>
  Reset configuration. Allows resetting AI state such as the conversation
  history or functions.
</ParamField>

<ParamField path="globalData" type="Record<string, unknown> | undefined" toc={true}>
  Update the global data accessible to the AI and SWAIG functions.
</ParamField>

## **Returns**

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

## **Example**

```typescript {19}
import { RelayClient } from '@signalwire/sdk';

const client = new RelayClient({
  project: process.env.SIGNALWIRE_PROJECT_ID!,
  token: process.env.SIGNALWIRE_TOKEN!,
  contexts: ['default']
});

client.onCall(async (call) => {
  await call.answer();

  // Start an AI agent
  const action = await call.ai({
    prompt: { text: 'You are a helpful assistant.' },
  });

  // Inject a system message after 10 seconds
  await new Promise((resolve) => setTimeout(resolve, 10_000));
  await call.aiMessage({
    messageText: 'The caller is a VIP customer. Be extra helpful.',
    role: 'system',
  });

  await action.wait();
});

await client.run();
```