| name | add-channel-gmail |
| description | Set up Gmail as a messaging channel — Google OAuth2, credentials, token exchange, and verification |
/add-channel-gmail — Add Gmail Channel
Walk the user through connecting Gmail to everclaw via Google OAuth2. This skill is standalone — run it from /setup or anytime to add Gmail. This is the most involved channel setup.
Instructions
Work through each phase in order. Use TaskCreate to track progress. Be autonomous: detect what's already done, only ask questions when a real choice is needed. Use the Read and Edit tools to modify .env. NEVER echo secrets to the terminal or pass them as bash arguments.
Phase 1: Preflight
-
Check .env exists in the project root. If not, tell the user to run /setup first and stop.
-
Read .env and check if CHANNEL_GMAIL is already set.
- If present, use
AskUserQuestion:
Gmail is already configured (CHANNEL_GMAIL is set in .env). What would you like to do?
- Keep it — Skip to verification
- Reconfigure — Set up from scratch (will need to re-authorize)
- If "Keep it", skip to Phase 4.
- If "Reconfigure", tell the user to delete
data/auth/gmail/ to clear old credentials before proceeding.
Phase 2: Configure — Google Cloud Console
Walk the user through creating OAuth2 credentials. This has many steps but each is straightforward.
-
Tell the user:
Create a Google Cloud project and enable the Gmail API:
- Go to the Google Cloud Console
- Click the project dropdown at the top and select New Project
- Name it (e.g., "everclaw") and click Create
- Make sure the new project is selected
- Go to APIs & Services → Library (left sidebar)
- Search for Gmail API and click Enable
Configure the OAuth consent screen:
- Go to APIs & Services → OAuth consent screen
- Select External user type (unless you have a Google Workspace org)
- Fill in the required fields (app name, user support email, developer contact email)
- Click Save and Continue through the remaining steps
- Under Test users, add the Gmail address you want the bot to use
Create OAuth2 credentials:
- Go to APIs & Services → Credentials
- Click Create Credentials → OAuth client ID
- Application type: Desktop app (or Web application if you prefer)
- Name it and click Create
- Click Download JSON to download the credentials file
-
Use AskUserQuestion:
Did you download the credentials JSON file? Paste the full path to the downloaded file (e.g., ~/Downloads/client_secret_123.json).
-
Copy the credentials file to the auth directory:
mkdir -p data/auth/gmail
cp "<user_provided_path>" data/auth/gmail/credentials.json
-
Append CHANNEL_GMAIL=1 to .env using the Edit tool. If reconfiguring, replace the existing line.
Phase 3: Restart and OAuth2 Authorization
This phase combines restart with the interactive OAuth2 flow.
Detect the deployment method:
- Check if
docker-compose.yml exists in the project root.
- If Docker: "Start/restart with
docker compose up --build — you need to see the terminal output for the OAuth URL."
- If bare metal: "Stop the bot (Ctrl+C) and restart with
node src/index.ts."
Important for Docker users: They need to run in foreground to see the OAuth URL.
After restart, the Gmail adapter will print an OAuth2 authorization URL and then throw an error (this is expected on first run). Walk the user through the token exchange:
Complete the OAuth2 authorization:
- Look in the logs for a URL starting with
https://accounts.google.com/o/oauth2/v2/auth?...
- Open that URL in your browser
- Sign in with the Gmail account the bot should use
- Click Allow to grant access (you may see a "This app isn't verified" warning — click Advanced → Go to [app name])
- After authorization, you'll be redirected. Copy the authorization code from the URL or page.
- Exchange it for a token by running this command (replace the placeholders):
curl -s -d "code=AUTH_CODE&client_id=YOUR_CLIENT_ID&client_secret=YOUR_SECRET&redirect_uri=YOUR_REDIRECT_URI&grant_type=authorization_code" https://oauth2.googleapis.com/token
You can find your client_id, client_secret, and redirect_uri in data/auth/gmail/credentials.json.
Use AskUserQuestion:
Paste the JSON response from the curl command (it contains access_token and refresh_token).
Read the response, validate it looks like a token response (has access_token), and save it:
Use the Write tool to save the token JSON to data/auth/gmail/token.json.
Tell the user to restart the bot again. This time the Gmail adapter should connect successfully — look for "Gmail connected" in the logs.
Phase 4: Discover chat ID
Check if ALLOWED_CHAT_IDS is already configured in .env (uncommented and non-empty).
If not configured (first channel):
Walk the user through discovery mode:
- "Send an email to the Gmail address connected to the bot (from a different email address)."
- "The bot will reply with the sender's chat ID — it looks like
gmail:sender@example.com. Check the bot's logs or outgoing email for this."
- Use
AskUserQuestion to collect the chat ID.
- Use the
Edit tool to set ALLOWED_CHAT_IDS=<chat_id> in .env. If the line is commented out, uncomment and set it.
If already configured (adding another channel):
- "Send an email to the bot's Gmail address."
- "The bot will reply with your chat ID. Check the logs or outgoing email."
- Use
AskUserQuestion to collect the chat ID.
- Use the
Edit tool to append the new ID to the existing ALLOWED_CHAT_IDS value (comma-separated).
After updating, tell the user to restart again.
Phase 5: Verify
- "Send a test email to the bot's Gmail address."
- "Within 30 seconds (the polling interval), the agent should process it and send a reply email."
- If it works — congratulations, Gmail is set up!
- If it doesn't respond:
- Check logs for errors
- Verify "Gmail connected" appears in startup logs
- Verify
data/auth/gmail/token.json exists and contains a refresh_token
- Verify
data/auth/gmail/credentials.json is valid
- Verify
ALLOWED_CHAT_IDS contains the right prefixed ID (e.g., gmail:sender@example.com)
- Make sure the bot is running
- Note: Gmail polls every 30 seconds — responses aren't instant
Tell the user they can add more channels later with /add-channel-telegram, /add-channel-discord, /add-channel-slack, or /add-channel-whatsapp.