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

# fact_treble_session_messages

> Every message exchanged inside conversation flows — the full trace.

# fact\_treble\_session\_messages

Each row is one message inside a conversation flow: what the bot (or an AI agent) sent, what the user replied, when it was delivered and read. This table did not exist in the previous warehouse — it gives you the complete transcript of every flow conversation.

## What questions does it answer?

* What exactly was said in a conversation, in order?
* Which messages fail to deliver, and with what error?
* How long do users take to read our messages?
* Which HSM templates are actually being sent inside flows?
* What did the AI reply in AI-powered conversations?

## Columns

| Column                  | Type       | Description                                                                                                                                                                 |
| ----------------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `message_id`            | Int64      | Unique identifier of the message                                                                                                                                            |
| `company_id`            | Int32      | Your company (filtered automatically)                                                                                                                                       |
| `session_id`            | Int64      | The conversation flow this message belongs to                                                                                                                               |
| `created_at`            | DateTime64 | When the message was created                                                                                                                                                |
| `sender`                | String     | Who sent it: `AI` (the automated flow), `USER` (the end user), or `HELPDESK_INTEGRATION` (sent through a connected CRM/helpdesk integration)                                |
| `type`                  | String     | Message type: `TEXT`, `HSM`, `IMAGE`, `AUDIO`, `VIDEO`, `DOCUMENT`, `STICKER`, `LOCATION`, `CONTACTS`, `WHATSAPP_FLOW`, `WHATSAPP_FLOW_RESPONSE`, `CALL_REQUEST_PERMISSION` |
| `text`                  | String     | Message text content                                                                                                                                                        |
| `file_url`              | String     | Media URL when the message carries a file                                                                                                                                   |
| `filename`              | String     | Original filename for documents                                                                                                                                             |
| `hsm_id`                | Int32      | HSM template used, if any; `0` otherwise                                                                                                                                    |
| `hsm_name`              | String     | HSM template name                                                                                                                                                           |
| `delivered_at`          | DateTime64 | When WhatsApp confirmed delivery; `NULL` if not (yet) delivered                                                                                                             |
| `read_at`               | DateTime64 | When the user read it; `NULL` if unread                                                                                                                                     |
| `error`                 | String     | Delivery error description; empty on success                                                                                                                                |
| `provider_msg_id`       | String     | WhatsApp message id (`wamid`)                                                                                                                                               |
| `reply_provider_msg_id` | String     | If the message quotes/replies to another, that message's `wamid`                                                                                                            |
| `interaction_answer_id` | Int64      | The flow step this message belongs to — join with `fact_treble_session_nodes.node_record_id`; `0` when the message is not tied to a step                                    |
| `contact_id`            | Int32      | Treble contact; `0` if none                                                                                                                                                 |
| `reaction`              | String     | Emoji reaction, if the user reacted to the message                                                                                                                          |
| `synced_at`             | DateTime64 | When this row was last written/corrected                                                                                                                                    |

## Example queries

### Reconstruct one conversation

```sql theme={null}
SELECT created_at, sender, type, text, delivered_at, read_at
FROM fact_treble_session_messages
WHERE session_id = {your_session_id}
ORDER BY created_at
```

### Delivery errors in the last 24 hours

```sql theme={null}
SELECT error, count() AS messages
FROM fact_treble_session_messages
WHERE created_at >= now() - INTERVAL 24 HOUR
  AND error != ''
GROUP BY error
ORDER BY messages DESC
```

<Note>
  Nearly every message carries `interaction_answer_id` — both the question the flow sent and the user's reply point to the same step. To pair answers with questions, join it against `fact_treble_session_nodes.node_record_id`.
</Note>
