{"id":30732402,"url":"https://github.com/pskinnertech/motion-slack-integration","last_synced_at":"2025-09-03T17:08:46.801Z","repository":{"id":296876826,"uuid":"994841493","full_name":"PSkinnerTech/motion-slack-integration","owner":"PSkinnerTech","description":"A simple API integration between Motion AI and Slack.","archived":false,"fork":false,"pushed_at":"2025-06-02T16:48:14.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-03T04:22:47.687Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PSkinnerTech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-02T15:04:03.000Z","updated_at":"2025-06-02T16:48:18.000Z","dependencies_parsed_at":"2025-06-03T04:40:15.667Z","dependency_job_id":null,"html_url":"https://github.com/PSkinnerTech/motion-slack-integration","commit_stats":null,"previous_names":["pskinnertech/motion-slack-integration"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PSkinnerTech/motion-slack-integration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSkinnerTech%2Fmotion-slack-integration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSkinnerTech%2Fmotion-slack-integration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSkinnerTech%2Fmotion-slack-integration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSkinnerTech%2Fmotion-slack-integration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PSkinnerTech","download_url":"https://codeload.github.com/PSkinnerTech/motion-slack-integration/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSkinnerTech%2Fmotion-slack-integration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273477122,"owners_count":25112616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-03T17:06:25.919Z","updated_at":"2025-09-03T17:08:46.791Z","avatar_url":"https://github.com/PSkinnerTech.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Motion to Slack Integration\n\nA simple integration that monitors your [Motion](https://usemotion.com) tasks and automatically posts to Slack when you complete them. Perfect for keeping your team updated on your progress without manual updates.\n\n## What is Motion?\n\n[Motion](https://usemotion.com) is an AI-powered productivity platform that combines your calendar, tasks, projects, and meeting assistant into one intelligent app. It uses AI to:\n\n- **Automatically prioritize and schedule your tasks** based on deadlines, dependencies, and your availability\n- **Manage projects with AI** that creates tasks, assigns work, and tracks progress automatically\n- **Take meeting notes** and generate action items without you lifting a finger\n- **Optimize your schedule** hundreds of times per day to ensure you never miss a deadline\n\nMotion helps individuals and teams get work done 2x faster with 90% fewer check-ins, emails, and status update meetings.\n\n## About This Integration\n\nThis is a **one-way integration** that:\n- 🔍 Polls Motion every minute for newly completed tasks\n- 📢 Posts formatted notifications to your chosen Slack channel\n- 🚫 Prevents duplicate notifications with state tracking\n- 🔄 Automatically retries on failures\n- 🚀 Deploys easily to Railway (or any Python host)\n- 🛡️ Includes robust error handling and environment validation\n\n## ⚡ Incredibly Efficient \u0026 Cost-Effective\n\nThis integration is designed to be **extremely lightweight** and cost-effective:\n\n### 📊 **Actual Production Costs**\n- **Railway Hobby Plan**: $5/month (includes $5 usage credit)\n- **Actual integration usage**: **~$0.20/month** 🤯\n- **Remaining credits**: $4.80/month for other projects\n- **Memory usage**: ~760 MB (minimal footprint)\n- **CPU usage**: Nearly zero (spends 99%+ time sleeping)\n- **Network traffic**: Minimal API calls only\n\n### 🚀 **Why So Efficient?**\n- **Smart polling**: Only checks Motion API once per minute\n- **Efficient sleep cycles**: Python's `time.sleep()` consumes no CPU while waiting\n- **Minimal dependencies**: Lightweight libraries (requests, python-dotenv)\n- **State tracking**: Prevents unnecessary duplicate processing\n- **Optimized API calls**: Only fetches completed tasks, not all tasks\n\n### 💡 **Cost Comparison**\n- **Actual usage**: $0.20/month = Only 4% of your Railway plan!\n- **Essentially free**: Uses only $0.20 of your $5 monthly Railway credits\n- **50x cheaper** than typical serverless solutions\n- **Way cheaper** than webhooks or real-time solutions\n- **No complex infrastructure** needed\n\nAt 20 cents per month, you get real-time task notifications without breaking the bank. This proves that simple polling solutions can be incredibly effective for low-frequency events like task completions!\n\n## Quick Start\n\n1. **Clone this repo**\n   ```bash\n   git clone https://github.com/PSkinnerTech/motion-slack-integration.git\n   cd motion-slack-integration\n   ```\n\n2. **Set up credentials** (see detailed instructions below)\n   - Get Motion API key from Motion settings\n   - Create a Slack bot with `chat:write` permission\n   - Find your Motion workspace ID\n\n3. **Configure environment**\n   ```bash\n   cp .env.example .env\n   # Edit .env with your credentials\n   ```\n\n4. **Deploy to Railway**\n   ```bash\n   railway login\n   railway init\n   railway up\n   ```\n\nThat's it! The bot will start posting your completed Motion tasks to Slack.\n\n## Features\n\n- ✅ Polls Motion API every 60 seconds for newly completed tasks\n- 📢 Posts task details to Slack with rich formatting including descriptions\n- 🔄 Tracks state to avoid duplicate notifications\n- 🚀 Railway-ready deployment with ultra-low costs (~$0.20/month)\n- 🛡️ Built-in error handling and retry logic\n- ⚡ **Extremely efficient**: Minimal CPU/memory usage with smart sleep cycles\n- 💰 **Cost-effective**: Simple polling beats complex architectures for this use case\n- 🔧 **Zero maintenance**: Runs continuously without intervention\n\n## Setup Instructions\n\n### 1. Prerequisites\n\n- **Motion account** with API access\n- **Slack workspace** where you have permission to create apps\n- **Python 3.9+** installed locally for development\n- **Railway account** (free tier works) or another hosting solution\n\n### 2. Getting Your Motion API Credentials\n\n#### API Key\n1. Log into [Motion](https://usemotion.com)\n2. Go to **Settings** → **API \u0026 Integrations**\n3. Click **\"Create New API Key\"**\n4. Copy the key immediately (it won't be shown again)\n5. Save it as `MOTION_API_KEY` in your .env file\n\n#### Workspace ID\n\n#### Workspace ID\n\n**Option 1: Use the helper script** (Recommended)\n```bash\n# After setting up your .env with MOTION_API_KEY\npython find_workspace_id.py\n```\n\n**Option 2: Manual method**\n1. Go to Motion and open your browser's Developer Tools (F12)\n2. Navigate to the Network tab\n3. Refresh the page or click around in Motion\n4. Look for API calls to `api.usemotion.com`\n5. Find a request that includes `workspaceId` in the URL or response\n6. Copy that workspace ID (it should be a UUID like `12345678-1234-1234-1234-123456789012`)\n7. Save it as `MOTION_WORKSPACE_ID` in your .env file\n\n### 3. Setting Up Slack Bot\n\nThis integration only needs a simple Slack bot that can post messages. Here's exactly what to do:\n\n#### Create the Slack App\n\n1. Go to [api.slack.com/apps](https://api.slack.com/apps)\n2. Click **\"Create New App\"**\n3. Choose **\"From scratch\"** (not from manifest)\n4. Enter:\n   - **App Name**: `Motion Task Notifier` (or your preferred name)\n   - **Workspace**: Select your workspace\n5. Click **\"Create App\"**\n\n#### Configure Bot Permissions\n\n1. In the left sidebar, click **\"OAuth \u0026 Permissions\"**\n2. Scroll down to **\"Scopes\"** section\n3. Under **\"Bot Token Scopes\"**, click **\"Add an OAuth Scope\"**\n4. Add these permissions:\n   - `chat:write` - Allows the bot to send messages\n   - `chat:write.public` - Allows posting to public channels without joining them\n\n#### Install the App to Your Workspace\n\n1. Scroll back to the top of the **\"OAuth \u0026 Permissions\"** page\n2. Click **\"Install to Workspace\"**\n3. Review the permissions and click **\"Allow\"**\n4. You'll now see a **\"Bot User OAuth Token\"** that starts with `xoxb-`\n5. **Copy this token** - this is your `SLACK_BOT_TOKEN` for the .env file\n\n#### Add the Bot to Your Channel\n\nIn Slack, go to your target channel (e.g., #dev-rel) and type:\n```\n/invite @Motion Task Notifier\n```\n(Use whatever name you gave your app)\n\n#### What You DON'T Need\n\nThis is a simple posting bot, so you can ignore these Slack app features:\n- ❌ Event Subscriptions\n- ❌ Interactivity \u0026 Shortcuts\n- ❌ Slash Commands\n- ❌ Incoming Webhooks\n- ❌ Socket Mode\n- ❌ Verification Token\n- ❌ Client ID/Secret\n- ❌ Signing Secret\n\nThese features are for receiving data FROM Slack or building interactive apps. We only need to POST to Slack.\n\n#### Test Your Bot Token\n\nTo verify your setup works, you can run this quick test:\n```python\nimport requests\n\ntoken = \"xoxb-YOUR-BOT-TOKEN-HERE\"\nresponse = requests.post(\n    \"https://slack.com/api/chat.postMessage\",\n    headers={\"Authorization\": f\"Bearer {token}\"},\n    json={\"channel\": \"#your-channel\", \"text\": \"Test message from Motion integration! 🚀\"}\n)\nprint(response.json())  # Should show \"ok\": true\n```\n\n### 4. Deploy to Railway\n\nRailway's **Hobby Plan ($5/month)** is perfect for this integration. You get $5 of usage credits monthly, and this integration only uses **~$0.20/month**, leaving you $4.80 for other projects!\n\n1. **Fork or clone this repository**\n\n2. **Install Railway CLI** (optional but recommended):\n   ```bash\n   npm install -g @railway/cli\n   ```\n\n3. **Create a new Railway project**:\n   ```bash\n   railway login\n   railway init\n   ```\n\n4. **Set environment variables in Railway**:\n   ```bash\n   railway variables set MOTION_API_KEY=your_motion_api_key_here\n   railway variables set MOTION_WORKSPACE_ID=12345678-1234-1234-1234-123456789012\n   railway variables set SLACK_BOT_TOKEN=xoxb-your-bot-token-here\n   railway variables set SLACK_CHANNEL=#dev-rel\n   ```\n\n5. **Deploy**:\n   ```bash\n   railway up\n   ```\n\n   Or deploy via GitHub:\n   - Connect your GitHub repo to Railway\n   - Railway will auto-deploy on push\n\n**💡 Pro tip**: With Railway's Hobby Plan, this integration is essentially \"free\" since it only uses 4% of your monthly credits!\n\n### 5. Local Development\n\n1. **Clone the repository**:\n   ```bash\n   git clone \u003cyour-repo-url\u003e\n   cd motion-slack-integration\n   ```\n\n2. **Quick start** (Linux/Mac):\n   ```bash\n   chmod +x quickstart.sh\n   ./quickstart.sh\n   ```\n\n   Or manually:\n\n2. **Install dependencies**:\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n3. **Create .env file**:\n   ```bash\n   cp .env.example .env\n   # Edit .env with your actual values\n   ```\n\n4. **Run locally**:\n   ```bash\n   python main.py\n   ```\n\n## Testing Your Setup\n\nBefore deploying to Railway, it's recommended to test your Motion API connection locally to ensure everything is configured correctly.\n\n### **Test Motion API Connection**\n\nThe project includes a comprehensive test script to validate your Motion API setup:\n\n```bash\npython test_motion_api.py\n```\n\n**What it tests:**\n- ✅ **API Key validation** - Confirms your Motion API key is working\n- ✅ **User authentication** - Verifies you can access your Motion account\n- ✅ **Workspace access** - Lists all your workspaces and confirms the target workspace ID\n- ✅ **Task retrieval** - Tests fetching tasks from your workspace\n- ✅ **Completed tasks** - Shows recent completed tasks to verify the integration will work\n\n**Example output:**\n```\n🧪 Testing Motion API Connection...\n\n✅ API Key found: dI/Bnrgo/qjVSyn3H5Cr...\n✅ Workspace ID: L8YNMqtk32fD7WkMl8Nym\n\n🔍 Test 1: Getting user info...\n✅ User: Patrick Skinner (patrick@clgcorporation.com)\n\n🔍 Test 2: Listing workspaces...\n✅ Found 6 workspace(s):\n  ✅ NVM (L8YNMqtk32fD7WkMl8Nym)\n  ⚪ My Tasks (Private) (K4lCA17lbuLxwD5aVaiGG)\n  ...\n\n🔍 Test 3: Checking workspace L8YNMqtk32fD7WkMl8Ym...\n✅ Workspace ID is valid and accessible\n\n🔍 Test 4: Getting tasks from workspace...\n✅ Found 204 tasks in workspace\n✅ Found 87 completed tasks\n\n🎉 All Motion API tests passed! The API is working correctly.\n```\n\n**If the test fails**, it will show you exactly what's wrong and suggest fixes:\n- Invalid API key → Regenerate your Motion API key\n- 401 Unauthorized → Check if you have Team/Enterprise plan (Individual plans don't have API access)\n- Workspace not found → Verify your workspace ID is correct\n\n**Run this test whenever:**\n- Setting up the integration for the first time\n- Getting deployment errors\n- Suspecting Motion API issues\n- After changing API keys or workspace IDs\n\n## Configuration\n\nAll configuration is done via environment variables. Create a `.env` file with:\n\n```bash\n# Required\nMOTION_API_KEY=your_motion_api_key_here\nMOTION_WORKSPACE_ID=12345678-1234-1234-1234-123456789012\nSLACK_BOT_TOKEN=xoxb-your-bot-token-here\n\n# Optional\nSLACK_CHANNEL=#dev-rel  # Default: #dev-rel\nPOLL_INTERVAL=60        # Default: 60 seconds\n```\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `MOTION_API_KEY` | Your Motion API key | Required |\n| `MOTION_WORKSPACE_ID` | Your Motion workspace ID (UUID format) | Required |\n| `SLACK_BOT_TOKEN` | Slack bot OAuth token (starts with xoxb-) | Required |\n| `SLACK_CHANNEL` | Slack channel to post to | #dev-rel |\n| `POLL_INTERVAL` | Seconds between checks | 60 |\n\n## Message Format\n\nWhen a task is completed, the bot posts:\n\n```\n✅ Task Completed: Design new landing page\n📝 Description: Create mockups for the new product landing page\n📁 Project: Website Redesign\n⏱️ Expected Duration: 2h 30m\n🎯 Priority: HIGH\n📊 Status: Done\n✓ Completed at: 3:45 PM\n```\n\n## Example Use Cases\n\n- **Team Visibility**: Keep your team updated on what you're completing without manual status updates\n- **Daily Standups**: Review yesterday's completions easily in Slack\n- **Time Tracking**: See how long tasks actually took vs estimates\n- **Project Progress**: Track completion velocity for specific projects\n- **Accountability**: Create a record of completed work\n\n## Troubleshooting\n\n### Motion API Issues\n\n**First, run the test script to diagnose the problem:**\n```bash\npython test_motion_api.py\n```\n\nThis will help identify if the issue is with your API key, workspace access, or Motion plan.\n\n### Motion API Access\n- **\"Unauthorized\" errors?** Make sure you have a Team or Enterprise Motion plan - Individual plans don't include API access\n- **Can't find API settings?** Look under Settings → API \u0026 Integrations (only visible on Team/Enterprise plans)\n\n### Environment Variables Not Loading in Railway?\nThe integration now includes enhanced error reporting that will show you exactly which environment variables are missing and what's available. Common fixes:\n1. **Set variables at the service level**: In Railway, click on your service (not just the project) and add variables there\n2. **Use the Raw Editor**: Go to Variables → Raw Editor and paste all variables at once\n3. **Redeploy after changes**: Railway sometimes needs a fresh deployment to pick up new variables\n4. **Check the logs**: The improved error messages will list all available environment variables (with sensitive values hidden)\n\n### Bot not posting messages?\n1. Check Railway logs: `railway logs`\n2. Ensure bot is invited to the channel: `/invite @Your Bot Name`\n3. Verify environment variables are set correctly\n4. Check that your Slack bot token starts with `xoxb-`\n\n### Getting rate limited?\n- The integration respects Motion's rate limits (12 req/min for individuals, 120 for teams)\n- If you see rate limit errors, the app will automatically retry\n\n### State file issues?\n- Delete `state.json` to reset and check all tasks from the last hour\n- The app will recreate the state file automatically\n\n### Can't find workspace ID?\n- Try the `find_workspace_id.py` script first\n- Check browser DevTools Network tab for `workspaceId` in Motion API calls\n- Look for URLs like: `api.usemotion.com/v1/tasks?workspaceId=...`\n\n## Architecture\n\n- **main.py**: Core polling loop and orchestration\n- **motion_client.py**: Motion API wrapper with retry logic\n- **slack_client.py**: Slack API wrapper\n- **state.json**: Tracks last check timestamp (created automatically)\n\n## Support\n\nFor Motion API issues, contact Motion support (teams only).\nFor integration issues, check the logs or open an issue.\n\n## Contributing\n\nContributions are welcome! This project is open source and we'd love your help making it better.\n\n### How to Contribute\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n### Ideas for Contributions\n\n- **Features**:\n  - Add support for task creation/update notifications\n  - Filter notifications by project or label\n  - Customizable message formats\n  - Slack thread support for related tasks\n  - Daily/weekly summary reports\n  \n- **Improvements**:\n  - Add tests\n  - Docker support\n  - More deployment options (Heroku, AWS Lambda, etc.)\n  - Web UI for configuration\n  - Better error messages\n  \n- **Integrations**:\n  - Support for other chat platforms (Discord, Teams, etc.)\n  - Two-way sync (create Motion tasks from Slack)\n  - Webhook support if/when Motion adds it\n\n### Development Setup\n\n1. Fork and clone the repo\n2. Create a virtual environment: `python -m venv venv`\n3. Install in development mode: `pip install -e .`\n4. Run tests: `pytest` (once tests are added)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\nCopyright (c) 2025 Patrick Skinner (PSkinnerTech)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpskinnertech%2Fmotion-slack-integration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpskinnertech%2Fmotion-slack-integration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpskinnertech%2Fmotion-slack-integration/lists"}