Automate Team Coffee Chats with n8n and Mattermost

Struggling to organize virtual coffee chats manually? This n8n workflow automates grouping and invites via Mattermost and Google Calendar, saving you hours each week.
cron
mattermost
function
+1
Workflow Identifier: 1614
NODES in Use: Cron, Mattermost, Function, Google Calendar
Automate coffee chats with n8n and Mattermost

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What This Workflow Does

This workflow runs every Monday at 10 AM to organize virtual coffee chats for team members in a Mattermost channel.

It collects active users, groups them into threes (or twos when needed), posts the groups in Mattermost, and sends Google Calendar invites with conference links.

The main purpose is to save time and avoid errors when setting up these chats manually.


Inputs, Process, and Outputs

Inputs

  • Mattermost Channel ID: Used to find users who want to join the coffee chat.
  • Mattermost API Credentials: Needed to read users and post messages.
  • Google Calendar Credentials: Used to send invites to user emails.

Processing Steps

  • Trigger: A Cron node starts the workflow every Monday at 10 AM.
  • Greeting: A Mattermost node sends a welcome message about upcoming groups.
  • Get Users: Another Mattermost node fetches all active users from the coffee chat channel.
  • Group Users: A Function node shuffles and divides users into groups of three or two.
  • Announce Groups: Another Mattermost node posts grouped usernames in the channel.
  • Send Invites: A Google Calendar node sends calendar events with Google Meet links to group members.

Outputs

  • Mattermost Messages: Introductory message plus group announcements in the coffee chat channel.
  • Calendar Invites: Google Calendar events sent to the emails of grouped users with meeting details.

Who Should Use This Workflow

This is for team leads or HR coordinators who want to save time creating virtual coffee chats for remote teams.

The workflow is helpful for any group using Mattermost and Google Calendar who wants fair, random groups and automatic invites.


Tools and Services Used


Beginner Step-by-Step: How to Use This Workflow in n8n

Download and Import

  1. Use the Download button on this page to get the workflow file.
  2. Open n8n editor where the workflow runs.
  3. Click top right menu, choose “Import from File”, and select the downloaded file.

Configure Credentials and IDs

  1. Add or update Mattermost API credentials inside n8n.
  2. Add or update Google Calendar OAuth2 credentials inside n8n.
  3. Update the Coffee Chat Mattermost Channel ID in all Mattermost nodes.
  4. If needed, adjust emails, calendar IDs, or other fields as the workflow comments show.

Test and Activate

  1. Run the workflow once manually to check for errors and correct output.
  2. Watch the Mattermost channel for test messages and check the Google Calendar for test invites.
  3. If all works, activate the workflow by toggling the active switch in n8n.

From now on, this workflow will run every Monday automatically.

You can also explore running self-host n8n if hosting on your own server is preferred.


Understanding the Grouping Function Code

The key piece is the Function node that organizes users into groups.

It first makes an array with usernames and emails, then shuffles it randomly.

Next, it creates groups of three from this shuffled array.

If the last group has only one person, it adds that person to the previous group, so no single-member group appears.

The code outputs grouped usernames and emails to be used for messages and calendar invites.

const ideal_group_size = 3;
let groups = [];
let data_as_array = [];
let newItems = [];

// Take all users from input
for (let j = 0; j < items.length; j++) {
  data_as_array.push({ username: items[j].json.username, email: items[j].json.email });
}

// Shuffle function
function shuffle(array) {
  let currentIndex = array.length, temporaryValue, randomIndex;

  while (currentIndex !== 0) {
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex--;
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
  }

  return array;
}

data_as_array = shuffle(data_as_array);

// Create groups of 3
for (let i = 0; i < data_as_array.length; i += ideal_group_size) {
  groups.push(data_as_array.slice(i, i + ideal_group_size));
}

// Avoid groups with single person
for (let k = 0; k < groups.length; k++) {
  if (groups[k].length === 1) {
    groups[k].push(groups[k - 1].shift());
  }
}

for (let l = 0; l < groups.length; l++) {
  newItems.push({ json: { groupsUsername: groups[l].map(a => a.username), groupsEmail: groups[l].map(b => b.email) } });
}

return newItems;

Customization Options

  • Change Group Size: Modify ideal_group_size inside the Function node for groups of 2, 4, or other.
  • Set Meeting Time: Update the Google Calendar node start and end time fields for preferred coffee chat times.
  • Edit Messages: Change greetings or group announcements in Mattermost nodes to add new text or emojis.
  • Multiple Channels: Duplicate relevant nodes and set different channel IDs for separate team coffee chats.
  • Add Reminders: Add a delayed Mattermost node triggered shortly before the meeting to remind group members.

Troubleshooting

  • No users found: Check the Mattermost Channel ID and verify users belong to that channel.
  • Function node errors: Make sure the user list is not empty and the JavaScript code is copied exactly.
  • Google Calendar invites not sent: Confirm user emails exist in Mattermost profiles and are correctly fetched.
  • Messages not posted: Verify Mattermost API credentials have posting permissions and channel IDs are correct.

Pre-Production Checklist

  • Confirm Mattermost API credentials have read and post permission for the coffee chat channel.
  • Make sure Google Calendar OAuth credentials have event write and conference scopes.
  • Test Cron node manually to ensure the workflow starts on schedule.
  • Run the user fetch Mattermost node alone to see active user list.
  • Check the Function node output groups for correctness and balance.
  • Send a test message using the Mattermost node to the target channel.
  • Try sending a calendar invite to your own email to confirm Google Calendar event creation.

Deployment Guide

Once fully tested, activate the workflow in n8n by turning on the active toggle.

The workflow will then run every Monday at 10 AM, handling the entire coffee chat setup automatically.

Monitor n8n execution logs for errors and check messages and calendar invites as confirmation.


Summary of Benefits and Results

✓ Saves around 2 hours weekly by automating group creation and invites.

✓ Eliminates manual errors like missed invites or uneven groups.

✓ Provides clear group announcements in Mattermost channels.

✓ Sends timely Google Calendar invites with conference links.

✓ Frees up coordinators to focus on other HR tasks.

Automate coffee chats with n8n and Mattermost

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

The workflow uses Mattermost API to get all active users from a specified coffee chat channel.
The function node adds that single person to the previous group to avoid single-member groups.
Mattermost API credentials with read and message permissions and Google Calendar OAuth2 credentials with event and invite scopes are required.
Download the workflow file, import it in n8n, update credentials and IDs, test it manually once, then activate it to run on schedule.
Author
Written By
Ritu Sanjali

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.