> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apten.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Message Sent

> Get notified when a message is sent to a visitor in webchat.

The `webchat.message.sent` webhook event is triggered whenever the AI or a human agent
sends a message in a webchat session. This can be used to track outgoing communication
and monitor agent activity.

## Payload

### AI Example

```json theme={null}
{
  "event": "webchat.message.sent",
  "data": {
    "sessionId": "550e8400-e29b-41d4-a716-446655440000",
    "orgId": "org-abc123",
    "profile": "Default Profile",
    "origin": "https://example.com/pricing",
    "messageId": "msg_a3c5e7f9",
    "content": "Yes — we offer monthly and annual billing. Want me to pull up pricing?",
    "sentBy": "ai",
    "createdAt": "2024-01-15T14:30:00Z"
  },
  "timestamp": "2024-01-15T14:30:00Z"
}
```

### Human Agent Example

```json theme={null}
{
  "event": "webchat.message.sent",
  "data": {
    "sessionId": "550e8400-e29b-41d4-a716-446655440000",
    "orgId": "org-abc123",
    "profile": "Default Profile",
    "origin": "https://example.com/pricing",
    "messageId": "msg_b4d6f8a0",
    "content": "Hi, I just jumped in — happy to answer any other questions.",
    "sentBy": "human",
    "agentUserId": "user_xyz789",
    "createdAt": "2024-01-15T14:30:00Z"
  },
  "timestamp": "2024-01-15T14:30:00Z"
}
```

## Properties

| Property           | Type   | Description                                                                                        |
| ------------------ | ------ | -------------------------------------------------------------------------------------------------- |
| `event`            | string | The webhook event type (`webchat.message.sent`).                                                   |
| `data.sessionId`   | string | The unique identifier for the webchat session.                                                     |
| `data.orgId`       | string | The Apten organization ID that owns the session.                                                   |
| `data.profile`     | string | The name of the webchat profile that handled the session.                                          |
| `data.origin`      | string | The URL of the page where the webchat widget was opened. Only included if set.                     |
| `data.messageId`   | string | The unique identifier for the message.                                                             |
| `data.content`     | string | The content of the message sent to the visitor.                                                    |
| `data.sentBy`      | string | Who sent the message: `ai` or `human`.                                                             |
| `data.agentUserId` | string | The Apten user ID of the human agent who sent the message. Only included when `sentBy` is `human`. |
| `data.createdAt`   | string | The ISO 8601 timestamp when the message was sent.                                                  |
| `timestamp`        | string | The ISO 8601 timestamp when the webhook was sent.                                                  |
