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.
- 🔁 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
slack-teams-sync/
├── src/
│ ├── index.ts # Entry point
│ └── app.ts # Slack + Teams logic
├── .env # Environment variables
├── package.json
├── tsconfig.json
└── README.md
git clone [email protected]:RedberryProducts/slack-to-teams-sync.git
cd slack-teams-syncnpm installCreate 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- Go to Slack API: Your Apps
- Create a new app from scratch
- Add the following OAuth scopes:
channels:historychat:writegroups:history
- Enable Event Subscriptions:
- Subscribe to
message.channelsandmessage.groups - Set Request URL to your ngrok URL (e.g.,
https://xxxx.ngrok.io/slack/events)
- Subscribe to
- Install the app to your workspace
- Open a channel in Microsoft Teams
- Click
...> Connectors > Incoming Webhook - Configure the webhook name and icon
- Copy the Webhook URL and add it to your
.envasTEAMS_WEBHOOK_URL
npm run devnpm run build
npm startUse ngrok in dev to expose your local server:
ngrok http 3000| 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": {
"start": "node dist/index.js",
"dev": "ts-node src/index.ts",
"build": "tsc"
}- Secrets are stored in
.env .envis included in.gitignoreby default- Never commit credentials to source control
Feel free to open issues or submit PRs for improvements like:
- Slack thread support
- Teams card enhancements
- Message filtering or formatting plugins