Skip to main content

Google Chat CLI - Send messages from the command line

Project description

gchat

A command-line interface for Google Chat. Send messages, read conversations, and search across your Google Chat spaces - all from the terminal.

Features

  • Multi-account support - Switch between work and personal accounts
  • Send messages - Quick one-liners or interactive mode
  • Read messages - View recent conversations in any space
  • Search - Find messages by keyword, sender, or date range
  • Beautiful TUI - Rich terminal output with tables and colors
  • JSON output - Machine-readable format for scripting and automation

Installation

Using pip

pip install gchat-cli

Using pipx (recommended)

pipx install gchat-cli

Using Homebrew (macOS)

brew tap chadsaun/tap
brew install gchat

From source

git clone https://github.com/chadsaun/gchat.git
cd gchat
pip install -e .

Quick Start

1. Set up Google Cloud credentials

Before using gchat, you need OAuth credentials from Google Cloud Console:

  1. Go to Google Cloud Console
  2. Create a new project (or select existing)
  3. Enable the Google Chat API
  4. Go to CredentialsCreate CredentialsOAuth client ID
  5. Select Desktop app as the application type
  6. Download the JSON file

2. Initialize gchat

gchat init

Follow the wizard to:

  • Name your account (e.g., "work" or "personal")
  • Provide the path to your credentials JSON file
  • Authenticate via browser

3. Start using gchat

# List your spaces
gchat spaces list

# Send a message
gchat send spaces/AAAA123 "Hello from the CLI!"

# Send interactively (select space, type message)
gchat send -i

# Read recent messages
gchat read spaces/AAAA123

# Search messages
gchat search spaces/AAAA123 "meeting notes"

Commands

Account Management

gchat account add [NAME]       # Add a new account
gchat account remove [NAME]    # Remove an account
gchat account list             # List all accounts
gchat account switch [NAME]    # Switch active account
gchat account current          # Show current account

Spaces

gchat spaces list              # List all spaces
gchat spaces list --format json  # JSON output
gchat spaces info SPACE_ID     # Get space details

Messaging

# Send a message
gchat send SPACE_ID "Your message"
gchat send -i                  # Interactive mode
gchat send SPACE_ID "msg" --no-confirm  # Skip confirmation

# Read messages
gchat read SPACE_ID            # Last 10 messages
gchat read SPACE_ID -n 50      # Last 50 messages
gchat read SPACE_ID --format json  # JSON output

Search

# Search by keyword
gchat search SPACE_ID "keyword"

# Filter by sender
gchat search SPACE_ID --from "john@example.com"

# Filter by date
gchat search SPACE_ID --after 2025-01-01
gchat search SPACE_ID --before 2025-01-31

# Combine filters
gchat search SPACE_ID "budget" --from "finance" --after 2025-01-01

Status

gchat status                   # Show current account and auth status
gchat status --format json     # JSON output

Multi-Account Usage

gchat supports multiple Google accounts. The active account persists until you switch:

# Add accounts
gchat account add work
gchat account add personal

# Switch between them
gchat account switch personal

# Or specify per-command
gchat spaces list --account work

JSON Output

All commands support --format json for scripting:

# Get spaces as JSON
gchat spaces list --format json | jq '.[] | .name'

# Send message and get result
gchat send SPACE_ID "Hello" --no-confirm --format json

Configuration

Configuration is stored in ~/.gchat/:

~/.gchat/
├── config.toml              # Main configuration
└── accounts/
    ├── work/
    │   ├── credentials.json # OAuth client config
    │   └── token.json       # OAuth tokens
    └── personal/
        ├── credentials.json
        └── token.json

Requirements

  • Python 3.11+
  • A Google Workspace account with Google Chat access
  • OAuth credentials from Google Cloud Console

License

MIT License - see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gchat_cli-0.2.1.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gchat_cli-0.2.1-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file gchat_cli-0.2.1.tar.gz.

File metadata

  • Download URL: gchat_cli-0.2.1.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gchat_cli-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0df1afe8edfd6c8fd759fd49a79f3fb3db28b3c61b8692da1db90dc62718721a
MD5 514047985338644af4cb68b3251ac220
BLAKE2b-256 eab5e79c59f6450e6b70e475c63823a78c4f5c0078ffe8cd85391247b8fd4a79

See more details on using hashes here.

Provenance

The following attestation bundles were made for gchat_cli-0.2.1.tar.gz:

Publisher: publish.yml on chadsaun/gchat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gchat_cli-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: gchat_cli-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 27.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gchat_cli-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5eab0bd178f4cf787c0e4002f5864c96b66642b8e482db7f420907530664253e
MD5 701001e8d862226bd6dbd7c362f6e3c6
BLAKE2b-256 4d936932417b24e628e7335f2a995d37cfdaeaeb9c7485b6c98a647cc1e97e11

See more details on using hashes here.

Provenance

The following attestation bundles were made for gchat_cli-0.2.1-py3-none-any.whl:

Publisher: publish.yml on chadsaun/gchat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page