---
title: "Get Messages"
description: "Fetch messages from a session by session id, with optional range and paging."
canonical_url: "https://docs.vettero.com/build/workflows/blocks/chat/get-messages"
---
# Get Messages

> Fetch messages from a session by session id, with optional range and paging.

<block-meta block="Yes" channels="Any" folder="chat" group="Chat" groupTo="/build/workflows/blocks/chat" icon="i-lucide-messages-square" pipe="Value" scope="Any" tool="Yes" type="chat.get-messages">



</block-meta>

**Get Messages** loads messages from a chat session. Use it after [Start Chat](https://docs.vettero.com/build/workflows/blocks/chat/start-chat), [Handover](https://docs.vettero.com/build/workflows/blocks/chat/handover), or whenever you already have a session id (for example `session.id` on a chat workflow).

## Configure

<table>
<thead>
  <tr>
    <th>
      Setting
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Session ID
      </strong>
    </td>
    
    <td>
      Session to read (required). Literal or variable
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        From Message ID
      </strong>
    </td>
    
    <td>
      Optional start of the range
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        To Message ID
      </strong>
    </td>
    
    <td>
      Optional end of the range
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Limit
      </strong>
    </td>
    
    <td>
      Max messages to return. Default <strong>
        50
      </strong>
      
      , 1–500
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Page
      </strong>
    </td>
    
    <td>
      Page number. Default <strong>
        1
      </strong>
    </td>
  </tr>
</tbody>
</table>

## Handles

<table>
<thead>
  <tr>
    <th>
      Handle
    </th>
    
    <th>
      Role
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        In
      </strong>
      
       (target)
    </td>
    
    <td>
      Incoming connection
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Out
      </strong>
      
       (source)
    </td>
    
    <td>
      Continues after messages are loaded
    </td>
  </tr>
</tbody>
</table>

## Pipe schema

The next block reads this on the data pipe (`pipe.value`).

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        messages
      </code>
    </td>
    
    <td>
      <code>
        list<Message>
      </code>
    </td>
    
    <td>
      Messages in chronological order
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        total
      </code>
    </td>
    
    <td>
      number
    </td>
    
    <td>
      How many messages were returned
    </td>
  </tr>
</tbody>
</table>

Each `Message` includes:

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        id
      </code>
    </td>
    
    <td>
      text
    </td>
    
    <td>
      Message id
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        from
      </code>
    </td>
    
    <td>
      object
    </td>
    
    <td>
      Sender: <code>
        type
      </code>
      
       (<code>
        agent
      </code>
      
       or <code>
        user
      </code>
      
      ) and <code>
        id
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        type
      </code>
    </td>
    
    <td>
      text
    </td>
    
    <td>
      Kind of message
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        content
      </code>
    </td>
    
    <td>
      any
    </td>
    
    <td>
      Text or a structured payload
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        timestamp
      </code>
    </td>
    
    <td>
      datetime
    </td>
    
    <td>
      When it was sent
    </td>
  </tr>
</tbody>
</table>

## Use case

- Load the last messages before [Summarize Chat](https://docs.vettero.com/build/workflows/blocks/chat/summarize).
- Inspect a range after handover using the start and end message ids on the handover pipe.

<block-page-nav>



</block-page-nav>


## Sitemap

See the full [sitemap](https://docs.vettero.com/sitemap.md) for all pages.
