Bot para o Google Chat do workspace weaura.tech.
┌─────────────────┐ ┌──────────────────────┐ ┌─────────────┐
│ Google Chat │────▶│ Cloud Function (Go) │────▶│ Aura API │
│ (Workspace) │◀────│ HTTP Endpoint │◀────│ (optional) │
└─────────────────┘ └──────────────────────┘ └─────────────┘
├── 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
- Acesse script.google.com
- Crie um novo projeto
- Cole o conteúdo de
apps-script/Code.gs - Configure o manifest
appsscript.json - Deploy como Google Chat App (ver instruções abaixo)
gcloudCLI autenticado com conta weaura.tech- Projeto GCP com billing habilitado
- APIs habilitadas: Cloud Functions, Chat API
# 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- Acesse Google Cloud Console → Chat API
- 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
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"}}'