🤖 Slack Bot - iFriend Busca Produtos¶
✅ Tratamento de Challenge do Slack - Implementado!¶
Este bot já está totalmente configurado para tratar o challenge do Slack automaticamente.
🎯 Como funciona¶
1. Challenge Automático¶
Quando você configura a URL no Slack, ele envia:
{"type": "url_verification", "challenge": "abc123"}
O AsyncSlackRequestHandler do Slack Bolt responde automaticamente:
{"challenge": "abc123"}
Você não precisa fazer nada! ✨
2. Endpoints Disponíveis¶
| Endpoint | Descrição |
|---|---|
POST /slack/events |
Recebe eventos do Slack (trata challenge automaticamente) |
GET /health |
Health check |
🚀 Deploy Rápido¶
# 1. Build e deploy
./deploy.sh
# 2. Anote a URL gerada
# Exemplo: https://seu-servico-xyz.run.app
# 3. Configure no Slack
# Em Event Subscriptions > Request URL:
# https://seu-servico-xyz.run.app/slack/events
🧪 Teste Local¶
# Inicie o servidor local
python test_server.py
# Em outro terminal, teste o health check
curl http://localhost:8080/health
# Teste o challenge
curl -X POST http://localhost:8080/slack/events \
-H "Content-Type: application/json" \
-d '{"type": "url_verification", "challenge": "test123"}'
📋 Variáveis de Ambiente¶
Configure estas variáveis no .env:
SLACK_BOT_TOKEN=xoxb-seu-token-aqui
SLACK_SIGNING_SECRET=seu-signing-secret
GOOGLE_APPLICATION_CREDENTIALS=service-account-key.json
📖 Documentação Completa¶
Veja SLACK_SETUP.md para instruções detalhadas.
🔧 Stack¶
- Framework: Slack Bolt (Python)
- Web Server: Starlette + Uvicorn
- Deploy: Gunicorn no Cloud Run
- Challenge: Tratado automaticamente pelo AsyncSlackRequestHandler