|
| 1 | +# Eliza Slack Client |
| 2 | + |
| 3 | +This package provides Slack integration for the Eliza AI agent. |
| 4 | + |
| 5 | +## Setup Guide |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | +- A Slack workspace where you have permissions to install apps |
| 9 | +- ngrok installed for local development (`brew install ngrok` on macOS) |
| 10 | +- Node.js and pnpm installed |
| 11 | + |
| 12 | +### Step 1: Start ngrok |
| 13 | +1. Open a terminal and start ngrok on port 3069 (or your configured port): |
| 14 | + ```bash |
| 15 | + ngrok http 3069 |
| 16 | + ``` |
| 17 | +2. Copy the HTTPS URL (e.g., `https://xxxx-xx-xx-xx-xx.ngrok-free.app`) |
| 18 | +3. Keep this terminal open - closing it will invalidate the URL |
| 19 | + |
| 20 | +### Step 2: Create Slack App |
| 21 | +1. Go to [Slack API Apps page](https://api.slack.com/apps) |
| 22 | +2. Click "Create New App" |
| 23 | +3. Choose "From an app manifest" |
| 24 | +4. Select your workspace |
| 25 | +5. Copy this manifest, replacing `YOUR_NGROK_URL` with your ngrok HTTPS URL: |
| 26 | + |
| 27 | +```yaml |
| 28 | +display_information: |
| 29 | + name: eve |
| 30 | + description: Eve ai16z |
| 31 | + background_color: "#143187" |
| 32 | +features: |
| 33 | + app_home: |
| 34 | + home_tab_enabled: true |
| 35 | + messages_tab_enabled: false |
| 36 | + messages_tab_read_only_enabled: false |
| 37 | + bot_user: |
| 38 | + display_name: eve |
| 39 | + always_online: false |
| 40 | +oauth_config: |
| 41 | + scopes: |
| 42 | + bot: |
| 43 | + - app_mentions:read |
| 44 | + - channels:history |
| 45 | + - channels:join |
| 46 | + - channels:read |
| 47 | + - chat:write |
| 48 | + - groups:history |
| 49 | + - groups:read |
| 50 | + - im:history |
| 51 | + - im:read |
| 52 | + - im:write |
| 53 | + - mpim:history |
| 54 | + - mpim:read |
| 55 | + - mpim:write |
| 56 | + - users:read |
| 57 | +settings: |
| 58 | + event_subscriptions: |
| 59 | + request_url: YOUR_NGROK_URL/slack/events |
| 60 | + bot_events: |
| 61 | + - app_mention |
| 62 | + - message.channels |
| 63 | + - message.groups |
| 64 | + - message.im |
| 65 | + - message.mpim |
| 66 | + interactivity: |
| 67 | + is_enabled: true |
| 68 | + request_url: YOUR_NGROK_URL/slack/interactions |
| 69 | + org_deploy_enabled: false |
| 70 | + socket_mode_enabled: false |
| 71 | + token_rotation_enabled: false |
| 72 | +``` |
| 73 | +
|
| 74 | +6. Click "Create" |
| 75 | +7. On the "Basic Information" page, scroll down to "App Credentials" |
| 76 | +8. Copy all the credentials - you'll need them in Step 3 |
| 77 | +
|
| 78 | +### Step 3: Configure Environment Variables |
| 79 | +1. Create or edit `.env` file in your project root: |
| 80 | + ```bash |
| 81 | + SLACK_APP_ID= # From Basic Information > App Credentials > App ID |
| 82 | + SLACK_CLIENT_ID= # From Basic Information > App Credentials > Client ID |
| 83 | + SLACK_CLIENT_SECRET= # From Basic Information > App Credentials > Client Secret |
| 84 | + SLACK_SIGNING_SECRET= # From Basic Information > App Credentials > Signing Secret |
| 85 | + SLACK_BOT_TOKEN= # From OAuth & Permissions > Bot User OAuth Token (starts with xoxb-) |
| 86 | + SLACK_VERIFICATION_TOKEN= # From Basic Information > App Credentials > Verification Token |
| 87 | + SLACK_SERVER_PORT=3069 # Must match the port you used with ngrok |
| 88 | + ``` |
| 89 | + |
| 90 | +### Step 4: Install the App |
| 91 | +1. In your Slack App settings, go to "Install App" |
| 92 | +2. Click "Install to Workspace" |
| 93 | +3. Review the permissions and click "Allow" |
| 94 | + |
| 95 | +### Step 5: Verify Installation |
| 96 | +1. Start your Eliza server |
| 97 | +2. Check the logs for successful connection |
| 98 | +3. Test the bot: |
| 99 | + - In Slack, invite the bot to a channel: `/invite @eve` |
| 100 | + - Try mentioning the bot: `@eve hello` |
| 101 | + - Check your server logs for event reception |
| 102 | + |
| 103 | +### Common Issues and Solutions |
| 104 | + |
| 105 | +#### URL Verification Failed |
| 106 | +- Make sure ngrok is running and the URL in your app settings matches exactly |
| 107 | +- Check that the `/slack/events` endpoint is accessible |
| 108 | +- Verify your environment variables are set correctly |
| 109 | + |
| 110 | +#### Bot Not Responding |
| 111 | +1. Check server logs for incoming events |
| 112 | +2. Verify the bot is in the channel |
| 113 | +3. Ensure all required scopes are granted |
| 114 | +4. Try reinstalling the app to refresh permissions |
| 115 | + |
| 116 | +#### Messages Not Received |
| 117 | +1. Verify Event Subscriptions are enabled |
| 118 | +2. Check the Request URL is correct and verified |
| 119 | +3. Confirm all bot events are subscribed |
| 120 | +4. Ensure the bot token starts with `xoxb-` |
| 121 | + |
| 122 | +### Updating ngrok URL |
| 123 | +If you restart ngrok, you'll get a new URL. You'll need to: |
| 124 | +1. Copy the new ngrok HTTPS URL |
| 125 | +2. Update the Request URLs in your Slack App settings: |
| 126 | + - Event Subscriptions > Request URL |
| 127 | + - Interactivity & Shortcuts > Request URL |
| 128 | +3. Wait for URL verification to complete |
| 129 | + |
| 130 | +### Security Notes |
| 131 | +- Never commit your `.env` file or tokens to version control |
| 132 | +- Rotate your tokens if they're ever exposed |
| 133 | +- Use HTTPS URLs only for Request URLs |
| 134 | +- Keep your ngrok and server running while testing |
| 135 | + |
| 136 | +## Development |
| 137 | + |
| 138 | +### Local Testing |
| 139 | +1. Start ngrok: `ngrok http 3069` |
| 140 | +2. Update Slack App URLs with new ngrok URL |
| 141 | +3. Start the server: `pnpm start` |
| 142 | +4. Monitor logs for events and errors |
| 143 | + |
| 144 | +### Debugging |
| 145 | +Enable detailed logging by setting: |
| 146 | +```bash |
| 147 | +DEBUG=eliza:* |
| 148 | +``` |
| 149 | + |
| 150 | +### Adding New Features |
| 151 | +1. Update the manifest if adding new scopes |
| 152 | +2. Reinstall the app to apply new permissions |
| 153 | +3. Update documentation for any new environment variables |
| 154 | + |
| 155 | +## Support |
| 156 | +For issues or questions: |
| 157 | +1. Check the Common Issues section above |
| 158 | +2. Review server logs for errors |
| 159 | +3. Verify all setup steps are completed |
| 160 | +4. Open an issue with: |
| 161 | + - Error messages |
| 162 | + - Server logs |
| 163 | + - Steps to reproduce |
0 commit comments