Skip to content

RedberryProducts/slack-to-teams-sync

Repository files navigation

📦 Slack to Microsoft Teams Sync Bot

This is a TypeScript-based Node.js application that listens to messages posted in a Slack channel and automatically forwards them to a Microsoft Teams channel using an incoming webhook.

🚀 Features

  • 🔁 Sync messages from Slack to Microsoft Teams in real-time
  • ✏️ Detect edited Slack messages and forward updates clearly
  • 💬 Preserve message structure including hyperlinks, attachments, and Markdown
  • 🔐 Secure token handling via .env
  • ⚙️ Built with @slack/bolt, Axios, and TypeScript

📁 Project Structure

slack-teams-sync/
├── src/
│   ├── index.ts             # Entry point
│   └── app.ts               # Slack + Teams logic
├── .env                     # Environment variables
├── package.json
├── tsconfig.json
└── README.md

🔧 Setup Instructions

1. Clone the project

git clone [email protected]:RedberryProducts/slack-to-teams-sync.git
cd slack-teams-sync

2. Install dependencies

npm install

🔐 Environment Variables

Create a .env file in the root directory:

SLACK_BOT_TOKEN=xoxb-your-slack-bot-token
SLACK_SIGNING_SECRET=your-slack-signing-secret
TEAMS_WEBHOOK_URL=https://outlook.office.com/webhook/...
PORT=3000

💡 How to Get Slack & Teams Credentials

👉 Slack Setup

  1. Go to Slack API: Your Apps
  2. Create a new app from scratch
  3. Add the following OAuth scopes:
    • channels:history
    • chat:write
    • groups:history
  4. Enable Event Subscriptions:
    • Subscribe to message.channels and message.groups
    • Set Request URL to your ngrok URL (e.g., https://xxxx.ngrok.io/slack/events)
  5. Install the app to your workspace

👉 Microsoft Teams Setup

  1. Open a channel in Microsoft Teams
  2. Click ... > Connectors > Incoming Webhook
  3. Configure the webhook name and icon
  4. Copy the Webhook URL and add it to your .env as TEAMS_WEBHOOK_URL

🧪 Run the App

Development (with ts-node):

npm run dev

Production:

npm run build
npm start

Use ngrok in dev to expose your local server:

ngrok http 3000

🧠 Behavior Overview

Slack Action Teams Result
New message Message sent to Teams
Edited message Message re-sent with Deployment Update title
Slack rich formatting Converted to Teams-compatible Markdown

📦 Scripts

"scripts": {
  "start": "node dist/index.js",
  "dev": "ts-node src/index.ts",
  "build": "tsc"
}

🛡️ Security

  • Secrets are stored in .env
  • .env is included in .gitignore by default
  • Never commit credentials to source control

🙌 Contributing

Feel free to open issues or submit PRs for improvements like:

  • Slack thread support
  • Teams card enhancements
  • Message filtering or formatting plugins

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published