Ir al contenido

Slack

El provider Slack integra tu trabajador digital con workspaces de Slack. Soporta:

  • Mensajes directos (DMs)
  • Mensajes en canales
  • Menciones de apps
  • Componentes interactivos (botones, menús)
  • Mensajería enriquecida con Block Kit
  • Slash commands
  • Respuestas en hilos
  • Un workspace de Slack
  • Acceso de administrador para crear una app de Slack
  1. Crea una app de Slack

    Ve a api.slack.com/apps y haz clic en “Create New App”:

    • Elige “From scratch”
    • Ingresa un nombre para la app (por ejemplo, “My Support Bot”)
    • Selecciona tu workspace
  2. Configura los scopes del bot token

    Ve a OAuth & PermissionsScopesBot Token Scopes:

    Scopes requeridos:

    • chat:write - Enviar mensajes
    • im:history - Leer el historial de DMs
    • im:write - Abrir DMs
    • users:read - Leer información de usuarios

    Scopes opcionales:

    • channels:history - Leer mensajes de canales
    • channels:read - Listar canales
    • files:read - Leer archivos
    • files:write - Subir archivos
  3. Habilita las suscripciones a eventos

    Ve a Event Subscriptions:

    • Habilita Events
    • Define Request URL: https://your-domain.com/webhook/slack/{tenant}/{team}

    Suscríbete a eventos del bot:

    • message.im - Mensajes por DM
    • message.channels - Mensajes en canales
    • app_mention - @mentions
  4. Habilita la interactividad

    Ve a Interactivity & Shortcuts:

    • Habilita Interactivity
    • Define Request URL: https://your-domain.com/webhook/slack/{tenant}/{team}/interactive
  5. Instala la app en el workspace

    Ve a Install AppInstall to Workspace

    Copia el Bot User OAuth Token (empieza con xoxb-)

  6. Obtén las credenciales de la app

    Desde Basic Information:

    • App ID
    • Configuration Token (para actualizaciones del manifest)
  7. Configura el provider

    answers.json
    {
    "messaging-slack": {
    "enabled": true,
    "public_base_url": "https://your-domain.ngrok-free.app",
    "api_base_url": "https://slack.com/api",
    "bot_token": "xoxb-xxx-xxx-xxx",
    "slack_app_id": "A07XXXXXX",
    "slack_configuration_token": "xoxe.xoxp-xxx"
    }
    }
  8. Ejecuta la configuración

    Ventana de terminal
    gtc setup --answers answers.json ./my-bundle
OpciónRequeridoDescripción
enabledHabilita/deshabilita el provider
public_base_urlURL pública para los webhooks
bot_tokenBot User OAuth Token (xoxb-...)
slack_app_idApp ID de Basic Information
slack_configuration_tokenNoPara actualizaciones automáticas del manifest
api_base_urlNoURL de la API de Slack (por defecto: https://slack.com/api)
- id: reply
type: reply
config:
message: "Hello! How can I help you?"

Slack usa el formato mrkdwn:

- id: formatted
type: reply
config:
message: |
*Bold* _Italic_ `code`
>Blockquote
• Bullet point

Usa Block Kit de Slack para layouts enriquecidos:

- id: rich_message
type: reply
config:
blocks:
- type: section
text:
type: mrkdwn
text: "*Welcome!*\nHow can I assist you today?"
- type: divider
- type: actions
elements:
- type: button
text:
type: plain_text
text: "Get Help"
action_id: "help_clicked"
value: "help"
- type: button
text:
type: plain_text
text: "View Status"
action_id: "status_clicked"
value: "status"
- id: ask_action
type: reply
config:
message: "What would you like to do?"
blocks:
- type: actions
elements:
- type: button
text:
type: plain_text
text: "Create Ticket"
style: primary
action_id: "create_ticket"
- type: button
text:
type: plain_text
text: "Cancel"
style: danger
action_id: "cancel"
- id: select_option
type: reply
config:
blocks:
- type: section
text:
type: mrkdwn
text: "Select a category:"
accessory:
type: static_select
action_id: "category_select"
options:
- text:
type: plain_text
text: "Technical Support"
value: "technical"
- text:
type: plain_text
text: "Billing"
value: "billing"
- text:
type: plain_text
text: "General"
value: "general"

Responde en un hilo:

- id: thread_reply
type: reply
config:
message: "This replies in the thread"
thread_ts: "{{original_message.thread_ts}}"
- id: upload_file
type: reply
config:
files:
- url: "https://example.com/report.pdf"
filename: "report.pdf"
title: "Monthly Report"

Mensajes visibles solo para un usuario:

- id: ephemeral
type: reply
config:
message: "Only you can see this"
ephemeral: true
user: "{{user_id}}"
flows/on_interaction.ygtc
name: handle_interaction
version: "1.0"
nodes:
- id: route_action
type: branch
config:
conditions:
- expression: "action_id == 'help_clicked'"
next: show_help
- expression: "action_id == 'create_ticket'"
next: create_ticket
default: unknown_action
- id: show_help
type: reply
config:
message: "Here's how I can help..."
triggers:
- type: block_action
target: route_action
- id: handle_select
type: branch
config:
conditions:
- expression: "selected_value == 'technical'"
next: technical_flow
- expression: "selected_value == 'billing'"
next: billing_flow
  1. Ve a Slash Commands en la configuración de tu app
  2. Crea un comando (por ejemplo, /support)
  3. Define Request URL hacia tu webhook

Manéjalo en tu flow:

flows/slash_command.ygtc
name: slash_command
version: "1.0"
nodes:
- id: handle_command
type: reply
config:
message: "Support bot at your service!"
response_type: in_channel # or "ephemeral"
triggers:
- type: slash_command
command: "/support"
target: handle_command
greentic.demo.yaml
tenants:
demo:
teams:
support:
channels:
slack:
provider: messaging-slack
config:
channel_id: "C1234567890"
tenants:
demo:
teams:
support:
channels:
slack-general:
provider: messaging-slack
config:
channel_id: "C1234567890"
slack-vip:
provider: messaging-slack
config:
channel_id: "C0987654321"
  1. Verifica Event Subscriptions:

    • Comprueba que Request URL sea correcta
    • Asegúrate de que los eventos estén habilitados
    • Verifica que el bot esté suscrito a los eventos correctos
  2. Revisa los permisos del bot:

    • Reinstala la app después de agregar scopes
    • Verifica que el bot esté en el canal
  3. Prueba el webhook:

    Ventana de terminal
    curl https://your-domain.com/webhook/slack/demo/default

Tu bot token es inválido o expiró. Obtén un token nuevo desde OAuth & Permissions.

  • Verifica que el ID del canal sea correcto
  • Asegúrate de que el bot haya sido agregado al canal
  • Comprueba que el canal no esté archivado

Los límites de velocidad de Slack varían según el método. Manéjalos con cuidado:

- id: reply
type: reply
config:
message: "Response"
retry_on_rate_limit: true
max_retries: 3

Greentic valida automáticamente:

  • La marca de tiempo de la solicitud
  • La firma usando el signing secret
  • La verificación del token