Squadcast Slack Sync is a tool that synchronizes Squadcast on-call schedules with Slack user groups. It ensures that your Slack user groups always reflect who is currently on-call in Squadcast, enabling seamless communication and incident response.
At Squadcast, our team relies heavily on Slack for internal communication and has developed extensive tooling around the platform over the years. While our Squadcast Slack bot excels at incident response and on-call management, it intentionally doesn't support Slack channel description updates due to engineering and design considerations. Implementing this feature would also require additional permissions when users install the bot in their workspaces.
For our internal on-call operations, our team used to manually update the description of a dedicated Slack channel for on-call related discussion after the weekly on-call handover process. We also used to manually update a Slack user group earlier, enabling team members to easily tag on-call engineers across the workspace.
Without this automation, team members would need to either visit the Squadcast web application or check the #sq-oncall channel to identify the current on-call engineer before posting messages elsewhere. So we built this small app to automate the above usecase.
Hope this will be useful for some companies. Feel free to open up issues or reach out to support if you run into any issues.
- Automatic Synchronization: Keep Slack user groups up-to-date with Squadcast on-call rotations
- Channel Topic Updates: Automatically update Slack channel topics with current on-call information
- Schedule Tagging: Use tags to define which Slack user groups correspond to which schedules
- Robust Error Handling: Detailed logging and error recovery
- Flexible Deployment: Run as a script, Python package, or Docker container
# Clone the repository
git clone https://github.com/SquadcastHub/sq-slack-sync.git
# Navigate to the project directory
cd sq-slack-sync
# Install dependencies
pip install -r requirements.txt
Set the following required environment variables:
Variable | Description | Required |
---|---|---|
SQUADCAST_REFRESH_TOKEN | Squadcast API refresh token | Yes |
SQUADCAST_TEAM_ID | ID of your Squadcast team | Yes |
SLACK_BOT_TOKEN | Slack bot user OAuth token | Yes |
SQUADCAST_TENANCY | Squadcast tenancy domain (default: squadcast.com) | No |
You can set these variables directly in your environment, in a .env
file, or pass them as Docker environment variables.
The application can also be configured using a config.json
file:
{
"sync_settings": {
"log_level": "INFO",
"log_file": "squadcast_slack_sync.log",
"timeout_seconds": 30
},
"slack_settings": {
"retry_attempts": 3,
"retry_delay_seconds": 2
},
"squadcast_settings": {
"sync_interval_minutes": 5
}
}
# Basic usage
python main.py
docker-compose up
You can deploy the sync tool as a scheduled Kubernetes CronJob using the files provided in the deployment/
folder:
-
Build and push your Docker image to a container registry:
docker build -t your-registry/sq-slack-sync:latest . docker push your-registry/sq-slack-sync:latest
-
Update the image name in
deployment/cronjob.yaml
:image: your-registry/sq-slack-sync:latest
-
Create base64-encoded secrets for the required environment variables:
echo -n "your-slack-token" | base64 echo -n "your-squadcast-refresh-token" | base64 echo -n "your-squadcast-team-id" | base64 echo -n "squadcast.com" | base64 # or your custom tenancy
-
Update
deployment/secrets.yaml
with the base64-encoded values:data: SLACK_BOT_TOKEN: <base64-encoded-token> SQUADCAST_REFRESH_TOKEN: <base64-encoded-token> SQUADCAST_TEAM_ID: <base64-encoded-id> SQUADCAST_TENANCY: <base64-encoded-tenancy>
-
Apply the Kubernetes manifests:
kubectl apply -f deployment/secrets.yaml kubectl apply -f deployment/cronjob.yaml
-
Verify the CronJob is created:
kubectl get cronjobs
By default, the CronJob is configured to run every hour. You can modify the schedule in the cronjob.yaml
file by updating the schedule
field using standard cron syntax.
- Get your Squadcast refresh token from the profile
- Find your team ID from the settings page
- Add tags to each schedule you want to sync:
- Required:
slack-usergroup-id
tag with the ID of the corresponding Slack user group (starts with 'S') - Optional:
slack-channel-id
tag with channel ID(s) where you want to update the topic with on-call information- Single channel:
C1234567890
- Multiple channels:
C1234567890,C0987654321
(comma-separated)
- Single channel:
- You can find Slack user group IDs and channel IDs in your Slack workspace settings
- Required:
- Create a Slack app in your workspace
- Option 1: Create manually with the following OAuth scopes:
usergroups:read
usergroups:write
users:read
users:read.email
chat:write
channels:write.topic
(required for channel topic updates)channels:manage
(required for channel topic updates)channels:read
(required for channel topic updates)
- Option 2: Use the provided manifest files:
- Go to api.slack.com/apps
- Click "Create New App" → "From an app manifest"
- Select your workspace and paste the contents of either:
manifests/slack_app.json
(JSON format)manifests/slack_app.yaml
(YAML format)
- Option 1: Create manually with the following OAuth scopes:
- Install the app to your workspace
- Copy the Bot User OAuth Token for the
SLACK_BOT_TOKEN
environment variable
- The
"slack-usergroup-id"
tag is essential for syncing schedules with Slack user groups. If this tag is not set for a schedule, the sync process will skip that schedule. - Ensure the bot has been added to all user groups it needs to manage
- Email addresses must match between Squadcast and Slack for user mapping to work
The application can automatically update Slack channel topics with current on-call information. This feature is enabled by adding a slack-channel-id
tag to your Squadcast schedules.
When schedules have the slack-channel-id
tag, the bot will update those channel topics with a formatted list of on-call engineers:
L1 Escalation Schedule: @john.doe @jane.smith
L2 Escalation Schedule: @mike.wilson @sarah.jones
How to enable:
- Add the
slack-channel-id
tag to your Squadcast schedules:- Tag key:
slack-channel-id
- Tag value: Channel ID (e.g.,
C1234567890
) or comma-separated IDs for multiple channels (e.g.,C1234567890,C0987654321
)
- Tag key:
- Add the bot to each target channel: In each channel, type
/invite @Squadcast Slack Sync
or add the bot through channel settings - The bot needs the
channels:write
permission (included in the manifest files)
Key benefits:
- Only schedules that are actively synced (have
slack-usergroup-id
tag) will appear in channel topics - Multiple schedules can update the same channel
- Multiple channels can be updated from a single schedule
- Usernames in the topic are clickable Slack mentions
# Clone the repository
git clone https://github.com/SquadcastHub/sq-slack-sync.git
cd squadcast-slack-sync
# Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
This project is licensed under the MIT License - see the LICENSE file for details.
For issues, questions, or contributions, please:
- Open an issue on GitHub
- Reach out to [email protected]