xTaskjs 1.0 ya está disponible: cuentas por rol, documentación y una interfaz personalizable.

Paquetes

@xtaskjs/bots

Unified bots runtime for Telegram, Slack, and WhatsApp adapters with gateway decorators.

npm install @xtaskjs/bots reflect-metadata Ruta del paquete: packages/bots

Resumen

Qué controla este paquete en el runtime

Bots adds a multi-platform messaging runtime to xtaskjs. It uses decorated gateway classes, adapter registration, and lifecycle-managed dispatch so bot workflows stay DI-friendly and consistent with the rest of the framework.

Qué ofrece

  • BotGateway(), OnCommand(), OnMessage(), and OnCallbackQuery() declare bot handlers on DI-managed classes.
  • BotsModule registers platform adapters such as Telegram, Slack, and WhatsApp in a single runtime.
  • Injectable services can publish messages and inspect runtime adapter state through bot service tokens.
  • Lifecycle integration starts and stops bot adapters together with application bootstrap and shutdown.

Cómo encaja

  • Pairs with @xtaskjs/security in webhook scenarios where signed payloads and protected audit routes are required.
  • Uses @xtaskjs/config in upstream samples for adapter credentials and runtime tuning.
  • Demonstrated by samples 26-bots_app and 27-bots_webhook_security_app.

Mapa de uso

Qué peso tiene este paquete dentro del runtime

Arranque

4/5

Inyección de dependencias

5/5

Mensajería

5/5

Seguridad

4/5

Integraciones

5/5

Flujo del paquete

Cómo atraviesa este paquete las fases del runtime de xtaskjs

Antes del arranque

Register bot adapters and decorate gateway handlers so dispatch metadata is available when the container initializes.

Durante CreateApplication()

Bots integration resolves handlers from DI-managed services, wires adapters, and starts runtime dispatch according to configuration.

Durante app.close()

Adapters and subscriptions are stopped with the rest of the lifecycle so webhook and polling resources shut down cleanly.

Superficie API

Exports representativos del paquete original

Uso

Flujo típico de adopción

1. Register adapters

Use BotsModule and adapter registration helpers to connect Telegram, Slack, WhatsApp, or custom transports.

2. Decorate gateway handlers

Apply BotGateway and event decorators for commands, messages, and callback payloads in DI-managed classes.

3. Secure webhook edges

Combine bots with @xtaskjs/security and @xtaskjs/config when signed webhooks and protected audit endpoints are required.

Ejemplo

Fragmento de referencia

Gateway-based bot handlers
import { Service } from "@xtaskjs/core";
import { BotGateway, OnCommand, OnMessage } from "@xtaskjs/bots";

@Service()
@BotGateway("telegram")
export class WelcomeGateway {
  @OnCommand("/start")
  async onStart(ctx: any) {
    await ctx.reply("Welcome to xtaskjs bots");
  }

  @OnMessage(/hello/i)
  async onHello(ctx: any) {
    await ctx.reply("Hello from xtaskjs");
  }
}

Ejemplos

Ejemplos oficiales para revisar después

Ejemplos de referencia: 26-bots_app and 27-bots_webhook_security_app