4 min readUpdated Mar 2, 2026

readMessages Logic Documentation

Purpose

The readMessages logic node is designed to fetch messages from a specific Microsoft Teams chat. It provides an interface to retrieve and display chat messages, which can be useful for analytics, reporting, or monitoring chat activity. By leveraging the Teams Chat integration, users can automate the retrieval of chat data for further processing or analysis.

Settings

The readMessages node accepts the following settings:

  1. chatId

    • Input Type: String
    • Description: This setting defines the unique identifier of the Teams chat from which messages will be fetched. It is a required parameter, meaning the function cannot be executed without it. If the chatId is not provided using the inputs object, the function will attempt to retrieve it from the config object.
    • Default Value: None (required)
  2. maxResults

    • Input Type: Numeric
    • Description: This setting determines the maximum number of chat messages to return, with valid values ranging from 1 to 50. If not explicitly provided, it defaults to 25 messages. Adjusting this setting allows users to control the volume of data retrieved, which can impact performance and processing time. If a value less than 1 or greater than 50 is provided, it will be constrained to these bounds.
    • Default Value: 25

How It Works

The readMessages function performs the following operations:

  1. Initialize Connection: Calls the BuildConnectionInstance function to establish a connection to the Teams chat integration, using the provided context.

  2. Input Handling: Retrieves the chatId and maxResults from either the inputs or the config object. It ensures that the maxResults value is a valid integer and is within the acceptable range (1-50).

  3. Error Handling: Checks if chatId is provided; if not, it returns an error indicating that the Chat ID is required. This ensures robust error management.

  4. Fetch Messages: Calls the listMessages method on the Teams chat integration instance, using the specified chatId and maxResults.

  5. Filter Messages: Processes the fetched messages to exclude system messages and format them using the TeamsChatIntegration.messageToRow function.

  6. Return Data: Compiles the results into an output format that includes the messages and metadata such as the chatId and the total number of results. If an error occurs during the process, it catches the error and returns a descriptive error message.

Expected Data

The readMessages node expects the following data:

The output generated includes:

Use Cases & Examples

Use Cases

  1. Chat Monitoring for Customer Support: Utilize readMessages to retrieve and analyze chat messages in a support channel to evaluate agent performance, response times, and customer sentiment.

  2. Data Analytics for Team Collaboration: Gather insights from team discussions in a specific project channel to identify frequently discussed topics, which can help in project management and resource allocation.

  3. Automated Reporting: Generate automated reports by fetching chat messages at regular intervals and summarizing key points for management review.

Example Configuration

Use Case: Chat Monitoring for Customer Support

In this example, a customer support team wants to monitor the chat messages in their Teams channel identified by the chat ID 12345-abcde. They want to retrieve up to 30 messages for analysis.

Sample Configuration:

json
{
  "inputs": {
    "chatId": "12345-abcde",
    "maxResults": 30
  },
  "config": {
    "chatId": "default-chat-id",  // Fallback if inputs.chatId is not provided
    "maxResults": 25                // Default if inputs.maxResults is not provided
  }
}

In this configuration, readMessages will fetch the last 30 messages from the specified chat, providing valuable insights into the customer interaction patterns within the team.

Note: Make sure to replace default-chat-id in the configuration with a relevant ID if no input is provided. The maxResults value of 30 will ensure that they are getting enough data for monitoring without overwhelming the system.