Chat Messages
Send and manage messages in Microsoft Teams chats
How it Works
The Chat Messages component talks to Microsoft Teams through the Microsoft Teams API. When you set it up, you choose a Microsoft Teams credential that contains the client ID, client secret, tenant ID, and scope. The component then uses that credential to authenticate and call the Teams API to send, read, or reply to messages in a chat or a direct conversation. All the work happens inside Nappai, so you don’t need to write any code.
Operations
This component offers several operations that you can select based on what you need to do. You can only use one operation at a time:
- Send Chat Message: Send a new message to a Teams chat.
- Get Chat Messages: Retrieve a list of recent messages from a Teams chat.
- Get Chat Message: Retrieve a single message by its ID.
- Reply to Message: Send a reply to an existing message.
- Get Direct Messages: Retrieve recent direct messages (one‑to‑one chats) for a user.
- Send Direct Message: Send a new direct message to a user.
To use the component, first select the operation you need in the Operation field.
Inputs
Mapping Mode
This component has a special mode called Mapping Mode. When you enable this mode using the toggle switch, an additional input called Mapping Data is activated, and each input field offers you three different ways to provide data:
- Fixed: You type the value directly into the field.
- Mapped: You connect the output of another component to use its result as the value.
- Javascript: You write Javascript code to dynamically calculate the value.
This flexibility allows you to create more dynamic and connected workflows.
Input Fields
The following fields are available to configure this component. Each field may be visible in different operations:
-
Credential: Select the Microsoft Teams credential you have configured in Nappai.
- Visible in: Send Chat Message, Get Chat Messages, Get Chat Message, Reply to Message, Get Direct Messages, Send Direct Message
-
Operation: Choose the action you want to perform.
- Visible in: Send Chat Message, Get Chat Messages, Get Chat Message, Reply to Message, Get Direct Messages, Send Direct Message
-
Chat ID: ID of the Teams chat.
- Visible in: Send Chat Message, Get Chat Messages, Get Chat Message, Reply to Message
-
Message Text: Content of the message to send.
- Visible in: Send Chat Message, Reply to Message, Send Direct Message
-
Message ID: ID of the message to reply to or retrieve.
- Visible in: Get Chat Message, Reply to Message
-
Message Count: Number of messages to retrieve (default: 20).
- Visible in: Get Chat Messages, Get Direct Messages
-
Recipient Email: Email address of the recipient for a direct message (leave empty to get all direct messages).
- Visible in: Get Direct Messages, Send Direct Message
-
Content Type: Type of content being sent.
- Visible in: Send Chat Message, Reply to Message, Send Direct Message
-
Attachments: List of attachments to send. Each attachment should be a dict with keys:
attachment_name
,url
(for URL attachments),file_path
(for file uploads),file_id
(for Nappai conversation files).- Visible in: Send Chat Message, Send Direct Message
-
Tool Name: The name of the tool that will be used when this component is connected as a tool.
- Visible in: Send Chat Message, Get Chat Messages, Get Chat Message, Reply to Message, Get Direct Messages, Send Direct Message
-
Tool Description: A detailed description of what this tool does.
- Visible in: Send Chat Message, Get Chat Messages, Get Chat Message, Reply to Message, Get Direct Messages, Send Direct Message
-
Tools arguments metadata: Defines the arguments metadata for the tools.
- Visible in: Send Chat Message, Get Chat Messages, Get Chat Message, Reply to Message, Get Direct Messages, Send Direct Message
-
Mapping Mode: Enable mapping mode to process multiple data records in batch.
- Visible in: Send Chat Message, Get Chat Messages, Get Chat Message, Reply to Message, Get Direct Messages, Send Direct Message
Outputs
- Data: The raw data returned from the Teams API (e.g., message details, list of messages).
- Tool: A tool representation that can be used by Nappai agents to call this component programmatically.
Usage Example
Scenario: You want to automatically send a welcome message to a new team member in a specific chat.
- Drag the Chat Messages component onto the canvas.
- In the Operation field, select Send Chat Message.
- Set Chat ID to the ID of the welcome chat.
- In Message Text, type “Welcome to the team, @${new_member_name}!” (you can use a mapped value for the member’s name).
- If you want to attach a welcome guide, add an attachment in the Attachments field with
attachment_name: "Guide"
,file_path: "/files/guide.pdf"
. - Make sure the Credential field points to your Microsoft Teams credential.
- Run the workflow. The component will post the message and return the message data in the Data output.
Related Components
- MicrosoftTeamChannelsComponent – Manage Teams channels (create, update, delete).
- MicrosoftTeamFilesComponent – Upload and download files in Teams.
- MicrosoftTeamEventsComponent – Create and manage Teams calendar events.
Tips and Best Practices
- Use Mapping Mode when you need to send the same message to many chats or users in a batch.
- Attach files only when necessary; large attachments can slow down the workflow.
- Keep the Message Count low (e.g., 10–20) to avoid long API calls when retrieving messages.
- Use the Reply to Message operation to keep conversations threaded and organized.
- Test with a small chat first to confirm the credential and chat ID are correct before running a large batch.
Security Considerations
- Store your Microsoft Teams credentials securely in Nappai’s credential store; never hard‑code them in workflows.
- The component uses OAuth 2.0 tokens that expire; Nappai handles token refresh automatically.
- Limit the scope of the credential to only the permissions needed (e.g.,
Chat.ReadWrite
for sending messages). - Review the permissions granted to the credential in Microsoft Entra to ensure least‑privilege access.