{"id":13646189,"url":"https://github.com/llmkira/claude-in-slack-server","last_synced_at":"2025-04-11T17:31:13.576Z","repository":{"id":156962316,"uuid":"633230127","full_name":"LlmKira/claude-in-slack-server","owner":"LlmKira","description":"⚡️ HTTP server that help you interact with Claude in slack, compatible with ChatGPT Web API.","archived":false,"fork":false,"pushed_at":"2023-09-28T18:05:52.000Z","size":48,"stargazers_count":62,"open_issues_count":5,"forks_count":19,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T16:21:41.425Z","etag":null,"topics":["claude","slack"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LlmKira.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}},"created_at":"2023-04-27T03:57:29.000Z","updated_at":"2024-11-11T05:04:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"29b5c8de-4229-4c79-8e9e-144bfd58425d","html_url":"https://github.com/LlmKira/claude-in-slack-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LlmKira%2Fclaude-in-slack-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LlmKira%2Fclaude-in-slack-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LlmKira%2Fclaude-in-slack-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LlmKira%2Fclaude-in-slack-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LlmKira","download_url":"https://codeload.github.com/LlmKira/claude-in-slack-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248449709,"owners_count":21105547,"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","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":["claude","slack"],"created_at":"2024-08-02T01:02:50.231Z","updated_at":"2025-04-11T17:31:13.145Z","avatar_url":"https://github.com/LlmKira.png","language":"Python","funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"# Claude in Slack Server API\n\nThis project starts an HTTP server that provides an API to interact with Claude in Slack. \n\nThis API is protected and configured by Slack's OAuth protocol, users only need to have a Slack account to interact with it.\n\nDon't want to build your own? Try mine: [Add to slack](https://chatgpt-proxy.lss233.com/claude-in-slack/login)\n\n\n## Installation\n\n```bash\ngit clone https://github.com/LlmKira/claude-in-slack-server\ncd claude-in-slack-server\npip install -r requirements.txt\n```\n\n## Usage\n\n### 1. Create a slack app\n\n1. Go to https://api.slack.com/apps, click `From an app manifest` - pick an workspace - next.  \n\n2. Go to `OAuth \u0026 Permissions` \u003e `Scopes`, and add following scopes:\n\nBot Token Scopes:  \n| OAuth Scope | Reasons |\n| ------------| ------------|\n| `channels:history` | Read conversation history and find claude's conversations. |\n| `users:read` | Find out the user id of claude and talk to it. |\n\n\nUser Token Scopes:  \n| OAuth Scope | Reasons |\n| ------------| ------------|\n| `chat:write` | Send messages on a user’s behalf. |\n\n3. Go to `OAuth \u0026 Permissions` \u003e `Redirect URLs`, and add a OAuth Redirect URL: `http://your_server_ip:5000/callback`  \nThis should be the same as the environment variable `SLACK_OAUTH_REDIRECT_URI` we defined later.\n\nYour `SLACK_BOT_TOKEN` is at `Bot User OAuth Token`.\n\n4. Go to `Event Subscriptions` \u003e `Enable Events` \u003e `Subscribe to bot events`, add a event:\n\n| Event Name | Reasons |\n| ------------| ------------|\n| `message.channels` | Receive claude's reply. |\n\n5. Go to `Socket Mode` \u003e `Enable Socket Mode`.\n\n6. Go to `Baisc Information` \u003e `App-Level Tokens` \u003e `Generate Tokens and Scopes`: \n\nToken Name: `SocketMode`\nScope: `connection:write`\n\nAnd you will get your `SLACK_APP_TOKEN` here.\n\n### 2. Start the server\n\nTo start this project, you will need to declare following environment variables:  \n| Key                        | Description                                            | Example                           |\n| --------------------------| -------------------------------------------------------| ----------------------------------|\n| APP_PORT                   | Server listen port                                     | 5000                              |\n| APP_HOST                   | Server listen host                                     | 0.0.0.0                         |\n| ENCRYPTION_KEY             | Key used to encrypt user's access_token                 | a_random_string                         |\n| SLACK_APP_TOKEN            | App token for Slack API                                 | xapp-1-A05xxxxxLGN8-517xxxxxxxxxx-b853xxxxxxxxxxxxxxxd34850xxxxxxxxxxbed3084|\n| SLACK_BOT_TOKEN            | Bot token for Slack API                                 | xoxb-517xxxxxxxxxx-51xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxx|\n| SLACK_OAUTH_CLIENT_ID      | Client ID for Slack API OAuth 2.0 authentication flow    | 1234567890                        |\n| SLACK_OAUTH_CLIENT_SECRET  | Client secret for Slack API OAuth 2.0 authentication flow| AbCdEfGhIjKlMnOpQrStUvWxYz123456 |\n| SLACK_OAUTH_REDIRECT_URI   | Redirect URI for Slack API OAuth 2.0 authentication flow | http://your_server_ip:5000/callback   |\n\nExample:\n```bash\nexport \"APP_PORT\"=\"5000\",\nexport \"APP_HOST\"=\"0.0.0.0\",\nexport \"ENCRYPTION_KEY\"=\"a_random_string\",\nexport \"SLACK_APP_TOKEN\"=\"xapp-1-A05xxxxxLGN8-517xxxxxxxxxx-b853xxxxxxxxxxxxxxxd34850xxxxxxxxxxbed3084\",\nexport \"SLACK_BOT_TOKEN\"=\"xoxb-517xxxxxxxxxx-51xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxx\",\nexport \"SLACK_OAUTH_CLIENT_ID\"=\"517xxxxxxxxxx.5xxxxxxxx\",\nexport \"SLACK_OAUTH_CLIENT_SECRET\"=\"xxxxxxxxxxxxxxxxxxx\",\nexport \"SLACK_OAUTH_REDIRECT_URI\"=\"http://your_server_ip:5000/callback\",\n```\n\n### 3. Users: Setting up access_token\n\n1. Visit `http://your_server_ip:5000/login`, Authorize your app to workspace.\nUsers will get a encrypted ACCESS_TOKEN.\n\n2. Invite your app and Claude to a channel of the workspace, and take down the channel id from url (starts with `C0`).\n\n\n### 4. Sending requests  \n\nOnce the server is started, you can visit `http://your_server_ip:5000/docs` to get the API docs.  \n\nThis API is designed to compatiable with OpenAI's ChatGPT web api, so you can interact with it using [revChatGPT (Python)](https://github.com/acheong08/ChatGPT) or [chatgpt-api (nodejs)](https://github.com/transitive-bullshit/chatgpt-api)  \n\nPython example:\n```python\nimport json\nimport uuid\nimport requests\n\ndef interact_with_server(channel_id, access_token, prompt, conversation_id=None):\n    payload = {\n        \"action\": \"next\",\n        \"messages\": [\n            {\n                \"id\": str(uuid.uuid4()),\n                \"role\": \"user\",\n                \"author\": {\n                    \"role\": \"user\"\n                },\n                \"content\": {\n                    \"content_type\": \"text\",\n                    \"parts\": [\n                        prompt\n                    ]\n                }\n            }\n        ],\n        \"conversation_id\": conversation_id,\n        \"parent_message_id\": str(uuid.uuid4()),\n        \"model\": \"claude-unknown-version\"\n    }\n\n    headers = {\n        'Authorization': f'Bearer {channel_id}@{access_token}',\n        'Content-Type': 'application/json'\n    }\n\n    response = requests.post(\"http://your_server_ip:5000/backend-api/conversation\", headers=headers, json=payload, timeout=60)\n    response.raise_for_status()\n\n    for line in response.iter_lines():\n        if not line or line is None:\n            continue\n        if \"data: \" in line:\n            line = line[6:]\n        if \"[DONE]\" in line:\n            break\n\n        try:\n            line = json.loads(line)\n        except json.decoder.JSONDecodeError:\n            continue\n\n        conversation_id = line[\"conversation_id\"]\n        message = line[\"message\"][\"content\"][\"parts\"][0]\n        yield (conversation_id, message)\n\n# Example usage\nchannel_id = 'C0XXXXXXX' # From Step 3\naccess_token = 'xxxxxxx' # From Step 3\nconversation_id = None\n\n# First call\nfor conversation_id, message in interact_with_server(channel_id, access_token, \"Can you say some emojis?\", conversation_id):\n    print(f\"Received message: {message}\")\n\n# Second call\nfor conversation_id, message in interact_with_server(channel_id, access_token, \"Can you use them to make a joke?\", conversation_id):\n    print(f\"Received message: {message}\")\n```\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllmkira%2Fclaude-in-slack-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fllmkira%2Fclaude-in-slack-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllmkira%2Fclaude-in-slack-server/lists"}