What This Automation Does
This workflow fetches messages from a Microsoft Teams channel from last week.
It sorts all messages by each user and uses OpenAI AI to make short reports for every person.
Then, it makes one big summary about the whole team.
Finally, it sends this report back to the Teams channel.
It helps save time and keeps everyone in the team up to date.
Who Should Use This Workflow
This is for people managing remote teams using Microsoft Teams chat a lot.
It is good when weekly meetings or summaries take too long or miss important talks.
Tools and Services Used
- Microsoft Teams API: To get and send chat messages.
- OpenAI API: To generate smart summaries using language models.
- n8n Automation Platform: To connect these services and run the whole workflow automatically.
Beginner Step-by-Step: How to Use This Workflow in n8n
Import the Workflow
- Download the workflow file by clicking the Download button on this page.
- Open your n8n editor where you want to use the flow.
- Select Import from File and pick the downloaded workflow to load it.
Configure the Workflow
- Add your Microsoft Teams API credentials with read and post rights.
- Add your OpenAI API Key for generating reports.
- Update team and channel IDs if your target channels are different.
- If needed, update any email addresses, folder names, or other IDs used in the flow for your setup.
- Check the Code node for JavaScript and the LLM Chain node prompts. You can copy and paste them directly if needed.
Run and Activate
- Test the workflow once to make sure it fetches messages and creates a report correctly.
- Fix any errors if they appear in the logs.
- When all works, activate the workflow so it runs every Monday automatically.
You can learn about self-host n8n if planning to keep this running on your own server.
Workflow Inputs, Processing, and Outputs
Inputs
- You provide Microsoft Teams team and channel IDs.
- n8n gets messages from the last 7 days using Microsoft Teams node.
- Your OpenAI API Key is needed for AI summarization.
Processing Steps
- Schedule trigger runs every Monday at 6 AM.
- Microsoft Teams node fetches all messages and replies from the previous week.
- Code node groups all messages by user ID. It links reply messages to their parents for context.
- SplitOut node separates each user’s grouped messages into single workflow items.
- Chain LLM node uses OpenAI to read all messages from one user and make a short report. It highlights wins, challenges, and notes team changes.
- Set node combines the user’s data with their AI report.
- Aggregate node collects all user reports into one list.
- Another Chain LLM node reads all individual reports and writes a unified team summary in markdown.
- Markdown node converts the markdown text into HTML for better display.
- Microsoft Teams node posts the final HTML report to the channel.
const messages = $input.all().map(item => item.json);
const groupByUserId = messages.reduce((acc, msg) => {
return {
...acc,
[msg.from.user.id]: acc[msg.from.user.id]
? acc[msg.from.user.id].concat(msg)
: [msg]
};
}, {});
const output = Object.keys(groupByUserId).map(userId => {
const userMessages = groupByUserId[userId];
for (let i = 0; i < userMessages.length; i++) {
if (userMessages[i].replyToId) {
userMessages[i].parent = messages.find(msg => msg.id === userMessages[i].replyToId);
}
}
return {
user: userMessages[0].from.user,
messages: userMessages
};
});
return { output };
The above script prepares user-based conversation groups with reply context.
Output
The end result is a clear, nicely formatted weekly report in Microsoft Teams.
It shows each member’s contributions and a team overview.
This saves time and improves team communication.
Customizations
- Change when the report runs by adjusting the Schedule Trigger node to any day or time.
- You can skip bots or some users by adding filters inside the Code node.
- Adjust AI prompt in Chain LLM nodes to make reports more formal, technical, or casual.
- Add other tools like ticketing APIs to include project stats in the summary.
- Send the report by Email by replacing or adding an Email node after the report generation.
Troubleshooting
- Issue: No messages fetched
Cause: Wrong team or channel ID, or missing permissions.
Fix: Double check the IDs in the Microsoft Teams node. Confirm API credentials can read messages. - Issue: OpenAI errors or slow
Cause: API limits or bad credentials.
Fix: Check your OpenAI API usage and keys. Add retries or error handling. - Issue: Reports missing important conversations
Cause: Message grouping or reply linking problems.
Fix: Review the JavaScript code linking replies. Make sure all messages are captured.
Pre-Production Checklist
- Confirm Microsoft Teams API keys can read and post messages.
- Test the Schedule Trigger node runs at the right time.
- Run the workflow manually to check all steps are correct.
- Check AI prompt outputs make sense for individual and team reports.
- Make sure the posted HTML looks good in the Teams channel.
Deployment Guide
Turn on the workflow by activating the schedule trigger in n8n.
Watch workflow runs to confirm messages fetched and reports created well.
Add alerts for errors from AI or API nodes to catch issues early.
Summary
✓ Workflow gathers Microsoft Teams channel chats from last week.
✓ AI creates user reports and team summary.
✓ Generates HTML report posted to Teams every Monday.
✓ Saves time and helps team stay informed.
✓ Easy to customize for tone and schedule.

