Connecting Google Services to OpenClaw: A Comprehensive Guide
Introduction OpenClaw is a powerful open source platform designed to create advanced AI driven chatbots capable of interacting with external services. By linking OpenClaw with G...
Introduction
OpenClaw is a powerful open-source platform designed to create advanced AI-driven chatbots capable of interacting with external services. By linking OpenClaw with Google tools like Gmail, Calendar, and Drive, users can automate tasks such as managing emails, scheduling, and handling documents. This guide will walk you through deploying OpenClaw on a DigitalOcean Droplet and configuring it to work with Google services using OAuth authentication.
Setting up OpenClaw requires setting up a dedicated Gmail account for security, configuring Google Cloud Console to enable API access, and establishing secure OAuth credentials. You'll transfer credentials to your Droplet, install necessary tools, and establish an SSH tunnel for secure browser-based authentication from your remote server.
By following this tutorial, you will have a fully functional OpenClaw installation running on DigitalOcean with authenticated access to Google services.
Key Takeaways
- OpenClaw is an AI-driven framework that integrates with Google services to automate tasks.
- A dedicated Gmail account improves security for your OpenClaw bot and separates its activities from personal accounts.
- Google Cloud Console requires OAuth 2.0 credentials and API activation for services your bot will access.
- The
gogclitool simplifies Google service authentication on servers through SSH tunneling. - SSH tunneling allows secure browser-based OAuth flows from a remote server.
Warning: Providing OpenClaw access to your Google services has inherent security risks. If your server is compromised, unauthorized users could access your Gmail, Google Calendar, and other connected services. It's recommended to use a separate Gmail account for your bot to protect your personal data.
Note: The setup process is detailed and requires multiple steps across various platforms. OpenClaw is under active development, and changes may render these instructions outdated. If you encounter issues, community feedback is valuable for keeping this guide accurate.
Step 1 — Creating an OpenClaw Droplet
Start by logging into your DigitalOcean account and creating a standard Ubuntu Droplet with 4-8 GB of RAM to install OpenClaw. Note the Droplet's IP address from the DigitalOcean Control Panel for use throughout the tutorial.
SSH into your Droplet using the command below, replacing your_server_ip with your Droplet’s IP address:
ssh root@your_server_ip
If connecting for the first time, confirm the host's authenticity by typing yes. Then, install OpenClaw by executing:
curl -fsSL https://openclaw.ai/install.sh | bash
Follow the on-screen prompts to select an AI option and provide the API key. You can also connect a communication channel, though this tutorial focuses on Google service integration.
Step 2 — Creating a Dedicated Gmail Account
Visit Google’s account creation page and create a new Gmail account with a name that identifies it as your bot’s account, such as yourproject-openclaw@gmail.com. Do not include personal information, contacts, or sensitive data in this account.
Complete the setup, including phone verification if needed. Record the email address and password for use in Google Cloud Console configuration.
Step 3 — Setting Up Google Cloud Console and OAuth
With your bot's Gmail account ready, configure Google Cloud Console to enable API access and create OAuth credentials.
Sign in to Google Cloud Console with your bot’s Gmail account. Select New Project and create a project named OpenClaw Google Integration. Switch to this project after creation.
Enabling Google APIs
Access the APIs & Services menu and enable the following:
- Gmail API
- Google Calendar API
- Google Drive API
You can enable additional APIs as needed, which will later be accessible to your bot.
Configuring OAuth Consent Screen
Set up the OAuth consent screen with the following:
- App name:
OpenClaw Google - User support email: Your bot’s email
- Audience: External
Complete the setup and publish the app.
Creating OAuth Credentials
Create OAuth credentials by selecting OAuth client ID for a Desktop app. Name it OpenClaw Desktop Client and download the credentials JSON file. Keep this file secure.
Step 4 — Transferring Credentials and Installing gogcli
Transfer the OAuth credentials file to your Droplet using:
scp "path/to/your/file.json" root@your_server_ip:~/google_oauth_client.json
Install gogcli on your Droplet:
cd /tmp
wget https://github.com/steipete/gogcli/releases/download/v0.11.0/gogcli_0.11.0_linux_amd64.tar.gz
tar -xzf gogcli_0.11.0_linux_amd64.tar.gz
sudo install -m 0755 gog /usr/local/bin/gog
Verify installation with gog --version.
Step 5 — Authenticating Google Services via SSH Tunnel
Authenticate your bot with Google services. Run the following command, replacing your_bot_gmail_address with your bot’s email:
gog auth add your_bot_gmail_address --services gmail,calendar,drive
Identify the port number in the URL generated by the command, then create an SSH tunnel:
ssh -N -L PORT:127.0.0.1:PORT root@your_server_ip
Complete the authentication in your local browser, granting all requested permissions.
Step 6 — Configuring OpenClaw Environment Variables
Set the passphrase as an environment variable for OpenClaw by editing the configuration file:
nano /root/.openclaw/.env
Add:
GOG_KEYRING_PASSWORD=your_password
Secure the file with chmod 600 /root/.openclaw/.env.
Add the variable to your shell environment:
echo 'export GOG_KEYRING_PASSWORD=$(grep GOG_KEYRING_PASSWORD /root/.openclaw/.env | cut -d= -f2)' >> ~/.bashrc
Configure OpenClaw’s gateway service with:
nano ~/.config/systemd/user/openclaw-gateway.service
Add:
Environment=GOG_KEYRING_PASSWORD=your_password
Reload the configuration and restart the service:
systemctl --user daemon-reload
systemctl --user restart openclaw-gateway
Step 7 — Confirming the Google Connection Functions
Access the OpenClaw text interface:
openclaw tui
Request your most recent email from your OpenClaw email address.
FAQ
- Why use a dedicated Gmail account? It reduces security risks by isolating the bot's activities from personal data.
- What if the OAuth URL expires? Generate a new URL by re-running the
gog auth addcommand. - Can I enable more Google APIs later? Yes, and you may need to re-authenticate for new services.
- How secure are stored OAuth credentials?
gogcliencrypts credentials, and proper file permissions enhance security.
Conclusion
This guide detailed deploying OpenClaw on a DigitalOcean Droplet and integrating it with Google services. With the setup complete, you can automate tasks like email management and document handling. Explore further to build complex automation workflows.