Skip to content

weauratech/gchat-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WeAura Tech - Google Chat Bot

Bot para o Google Chat do workspace weaura.tech.

Arquitetura

┌─────────────────┐     ┌──────────────────────┐     ┌─────────────┐
│  Google Chat    │────▶│  Cloud Function (Go)  │────▶│  Aura API   │
│  (Workspace)    │◀────│  HTTP Endpoint        │◀────│  (optional) │
└─────────────────┘     └──────────────────────┘     └─────────────┘

Estrutura

├── apps-script/          # Versão Apps Script (simples, como no lab)
│   ├── Code.gs           # Lógica principal do bot
│   └── appsscript.json   # Manifest do projeto
├── cloud-function/       # Versão Cloud Function (Go, produção)
│   ├── cmd/
│   │   └── main.go       # Entry point
│   ├── internal/
│   │   ├── handler/      # HTTP handlers para eventos do Chat
│   │   └── chat/         # Lógica de mensagens e cards
│   ├── go.mod
│   └── go.sum
├── deploy/               # Scripts de deploy
│   └── setup.sh          # Setup do GCP project
├── .github/
│   └── workflows/
│       └── deploy.yml    # CI/CD com GitHub Actions
└── terraform/            # IaC (opcional)
    └── main.tf

Setup Rápido (Apps Script)

  1. Acesse script.google.com
  2. Crie um novo projeto
  3. Cole o conteúdo de apps-script/Code.gs
  4. Configure o manifest appsscript.json
  5. Deploy como Google Chat App (ver instruções abaixo)

Setup Produção (Cloud Function + Go)

Pré-requisitos

  • gcloud CLI autenticado com conta weaura.tech
  • Projeto GCP com billing habilitado
  • APIs habilitadas: Cloud Functions, Chat API

Deploy

# Autenticar
gcloud auth login

# Configurar projeto
gcloud config set project <PROJECT_ID>

# Habilitar APIs
gcloud services enable \
  cloudfunctions.googleapis.com \
  cloudbuild.googleapis.com \
  chat.googleapis.com \
  run.googleapis.com

# Deploy da Cloud Function
cd cloud-function
gcloud functions deploy gchat-bot \
  --gen2 \
  --runtime=go122 \
  --region=us-central1 \
  --source=. \
  --entry-point=HandleChat \
  --trigger-http \
  --allow-unauthenticated

Configurar no Google Chat API

  1. Acesse Google Cloud Console → Chat API
  2. Em Configuration:
    • App name: WeAura Bot
    • Avatar URL: (seu avatar)
    • Description: Bot interno WeAura Tech
    • Functionality: marque "Receive 1:1 messages" e "Join spaces and group conversations"
    • Connection settings: HTTP endpoint URL → cole a URL da Cloud Function
    • Visibility: Everyone in weaura.tech

Desenvolvimento Local

cd cloud-function
go run cmd/main.go
# Servidor local em :8080

# Testar
curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{"type":"MESSAGE","message":{"text":"Olá bot"}}'

About

Google Chat bot for WeAura Tech workspace

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors