Using the For each message in a chat iterator
- Updated: 2025/08/22
Use the For each message in a chat iterator to loop through all messages within a specific Microsoft Teams chat (one-on-one or group) enabling you to automate actions such as reading, analyzing, or processing each message. This facilitates operations such as extracting information, monitoring conversations, or triggering workflows based on message content.
Procedure
- Double-click or drag the Loop action from the Loop package in the Actions palette.
- Select the For each message in a chat option from the Iterator list.
- Use the Session name field to select one of the following
options:
- Session name: Enter the name of the session used
to open the presentation with the Connect
action.
(Optional) Click the Insert a value icon to select an existing variable that you have used to store the default session name.
- Variable: Enter the name of the variable that you have used to store the session name.
- Session name: Enter the name of the session used
to open the presentation with the Connect
action.
- Select one of the following Chat options to specify the recipient to
retrieve their message:
- Username: Specifies the user’s email, user principal name or user's unique ID for one-on-one chats. The iterator will loop through messages in the direct chat with this user.
- Groupname: Indicates the display name of a group chat. Use this to iterate through messages in a specific group chat.
- Chat ID: The unique identifier assigned to a specific chat (either one-on-one or group). Use this when you have the chat’s ID to directly access and loop through its messages.
These options help you precisely select which chat’s messages to process in your automation.
- Use the Start date and End date options to filter messages within a specified date range.
- In the Assign message details to variablefield, choose
either Multiple variables or Dictionary
variable to save the output:
- Multiple variables: Assigns each retrieved value
(for example, ID, message,
sentByUserID, sentByUsername,
createdDateTime, and modifiedDateTime)
to a separate variable enabling you to map each team detail to a
specific variable. Do following steps for each variable:
- Click Add variable mapping.
- Enter the Key of the variable.
- In the Map to variable field, choose a variable where the data will be saved.
- Click Add for this data to be saved to the configured variable.
- Dictionary: stores all values in a dictionary object with key-value pairs.
- Multiple variables: Assigns each retrieved value
(for example, ID, message,
sentByUserID, sentByUsername,
createdDateTime, and modifiedDateTime)
to a separate variable enabling you to map each team detail to a
specific variable. Do following steps for each variable: