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

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

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

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

  • n8n Automation Platform: Runs the workflow and connects all nodes.
  • Mattermost API: Reads user list and posts messages in the coffee chat channel.
  • Google Calendar API: Creates calendar events and conference links for virtual meetings.

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.

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.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free