npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nestjs-automata-kit

v1.0.0

Published

NestJS Automata Kit - Powerful automation package for seamless integrations with n8n, Zapier, Make, Slack, Telegram, WhatsApp, and more

Readme

NestJS Automata Kit

npm version npm downloads License: MIT

A powerful NestJS package for seamless automation integrations with popular platforms like Slack, Telegram, n8n, Zapier, Make, WhatsApp, Google Sheets, and more.

🚀 Features

  • TypeScript First: Built with TypeScript for type safety and better developer experience
  • Decorator-Based: Use elegant decorators for webhook handling and service integration
  • Multiple Drivers: Built-in support for 10+ popular automation platforms
  • Dependency Injection: Full NestJS DI support for easy testing and customization
  • Webhook Management: Auto-generated secure webhook endpoints with signature verification
  • Event-Driven: Reactive programming with RxJS observables
  • Modular Design: Import only what you need
  • Production Ready: Comprehensive logging, error handling, and security features

📦 Installation

npm install nestjs-automata-kit
# or
yarn add nestjs-automata-kit

⚙️ Basic Setup

1. Import the module

import { Module } from '@nestjs/common';
import { AutomationModule } from 'nestjs-automata-kit';

@Module({
  imports: [
    AutomationModule.forRoot({
      drivers: {
        slack: {
          webhookUrl: process.env.SLACK_WEBHOOK_URL,
          botToken: process.env.SLACK_BOT_TOKEN,
        },
        telegram: {
          botToken: process.env.TELEGRAM_BOT_TOKEN,
        },
      },
      webhooks: {
        enabled: true,
        security: {
          verifySignatures: true,
        },
      },
    }),
  ],
})
export class AppModule {}

2. Environment Variables

Add to your .env file:

# Slack
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_SIGNING_SECRET=your-signing-secret

# Telegram
TELEGRAM_BOT_TOKEN=your-bot-token

# n8n
N8N_WEBHOOK_URL=https://your-n8n-instance.com/webhook/your-id
N8N_API_KEY=your-api-key

🎯 Quick Start

Sending Messages

import { Injectable } from '@nestjs/common';
import { AutomationService } from 'nestjs-automata-kit';

@Injectable()
export class NotificationService {
  constructor(private readonly automation: AutomationService) {}

  async sendSlackNotification(message: string) {
    const sender = await this.automation.to('slack');
    return sender.send({
      text: message,
      channel: '#notifications',
    });
  }

  async sendTelegramMessage(chatId: string, text: string) {
    const sender = await this.automation.to('telegram');
    return sender.send({
      chat_id: chatId,
      text: text,
      parse_mode: 'Markdown',
    });
  }
}

Handling Webhooks

import { Controller, Post } from '@nestjs/common';
import { 
  WebhookPayload, 
  WebhookHeaders, 
  WebhookService 
} from 'nestjs-automata-kit';

@Controller('my-webhooks')
export class MyWebhookController {
  @Post('slack')
  async handleSlackWebhook(
    @WebhookPayload() payload: any,
    @WebhookHeaders() headers: Record<string, string>,
  ) {
    if (payload.event?.type === 'app_mention') {
      // Bot was mentioned
      return { challenge: payload.challenge };
    }
    return { status: 'ok' };
  }

  @Post('telegram')
  async handleTelegramWebhook(@WebhookPayload() update: any) {
    if (update.message) {
      console.log('Received message:', update.message.text);
    }
    return { status: 'ok' };
  }
}

Using Built-in Webhook Controller

The package provides automatic webhook endpoints:

POST /webhooks/slack
POST /webhooks/telegram
POST /webhooks/n8n
POST /webhooks/slack/event-name
POST /webhooks/telegram/update-type

🔧 Available Drivers

Communication Platforms

  • Slack: Send messages, handle events, slash commands
  • Telegram: Send messages, handle updates, inline keyboards
  • Discord: Send messages via webhooks
  • WhatsApp: Send messages via WhatsApp Business API

Automation Platforms

  • n8n: Trigger workflows, handle responses
  • Zapier: Send data to Zapier webhooks
  • Make (Integromat): Trigger Make scenarios

Business Tools

  • HubSpot: CRM operations
  • Airtable: Database operations
  • Google Sheets: Spreadsheet operations
  • Google Drive: File management

🎨 Advanced Usage

Custom Drivers

Create your own automation drivers:

import { Injectable } from '@nestjs/common';
import { BaseDriver } from 'nestjs-automata-kit';

@Injectable()
export class CustomServiceDriver extends BaseDriver {
  getName(): string {
    return 'custom_service';
  }

  async send(data: any, options?: any): Promise<any> {
    const apiKey = this.getConfigValue('CUSTOM_API_KEY');
    
    return this.makeRequest('POST', 'https://api.example.com/webhook', {
      headers: { 'Authorization': `Bearer ${apiKey}` },
      data,
    });
  }

  async handleWebhook(payload: any): Promise<any> {
    return { service: 'custom_service', payload, processed: true };
  }
}

Async Configuration

@Module({
  imports: [
    AutomationModule.forRootAsync({
      useFactory: async (configService: ConfigService) => ({
        drivers: {
          slack: {
            webhookUrl: configService.get('SLACK_WEBHOOK_URL'),
            botToken: configService.get('SLACK_BOT_TOKEN'),
          },
        },
        webhooks: { enabled: true },
      }),
      inject: [ConfigService],
    }),
  ],
})
export class AppModule {}

Event Handling with Observables

@Injectable()
export class WebhookEventHandler {
  constructor(private readonly automation: AutomationService) {}

  async handleOrderCreated(order: any) {
    // Send to multiple services simultaneously
    const notifications = [
      this.automation.to('slack').then(s => s.send({
        text: `🛒 New order #${order.id} - $${order.total}`,
        channel: '#orders'
      })),
      
      this.automation.to('telegram').then(s => s.send({
        chat_id: process.env.ADMIN_CHAT_ID,
        text: `New order received: $${order.total}`
      })),
    ];

    await Promise.all(notifications);
  }
}

🔒 Security

Webhook Signature Verification

AutomationModule.forRoot({
  webhooks: {
    security: {
      verifySignatures: true,
      allowedIPs: ['192.168.1.0/24'],
      requireHTTPS: true,
    },
  },
})

Custom Guards

import { Injectable, CanActivate } from '@nestjs/common';

@Injectable()
export class WebhookGuard implements CanActivate {
  canActivate(context: ExecutionContext): boolean {
    const request = context.switchToHttp().getRequest();
    // Custom webhook validation logic
    return true;
  }
}

@Controller('secure-webhooks')
@UseGuards(WebhookGuard)
export class SecureWebhookController {
  // Protected webhook endpoints
}

🧪 Testing

import { Test } from '@nestjs/testing';
import { AutomationModule, AutomationService } from 'nestjs-automata-kit';

describe('AutomationService', () => {
  let service: AutomationService;

  beforeEach(async () => {
    const module = await Test.createTestingModule({
      imports: [
        AutomationModule.forRoot({
          drivers: {
            slack: { webhookUrl: 'https://test.webhook.url' },
          },
        }),
      ],
    }).compile();

    service = module.get<AutomationService>(AutomationService);
  });

  it('should send slack message', async () => {
    const sender = await service.to('slack');
    const result = await sender.send({ text: 'test message' });
    expect(result).toBeDefined();
  });
});

📚 Real-World Examples

E-commerce Order Processing

@Injectable()
export class OrderService {
  constructor(private readonly automation: AutomationService) {}

  async processOrder(order: CreateOrderDto) {
    // Save order to database
    const savedOrder = await this.orderRepository.save(order);

    // Notify team
    const slackSender = await this.automation.to('slack');
    await slackSender.send({
      text: `🛒 New order #${savedOrder.id}`,
      blocks: [
        {
          type: 'section',
          fields: [
            { type: 'mrkdwn', text: `*Customer:* ${order.customerName}` },
            { type: 'mrkdwn', text: `*Total:* $${order.total}` },
          ]
        }
      ]
    });

    // Update CRM via n8n workflow
    const n8nSender = await this.automation.to('n8n');
    await n8nSender.send({
      customerId: order.customerId,
      orderTotal: order.total,
      items: order.items,
    });

    return savedOrder;
  }
}

Customer Support Bot

@Controller('webhooks')
export class SupportBotController {
  constructor(private readonly automation: AutomationService) {}

  @Post('telegram')
  async handleTelegramUpdate(@WebhookPayload() update: any) {
    if (update.message?.text?.startsWith('/support')) {
      const telegramSender = await this.automation.to('telegram');
      
      await telegramSender.send({
        chat_id: update.message.chat.id,
        text: '🎫 Support ticket created! Our team will respond soon.',
        reply_markup: {
          inline_keyboard: [[
            { text: '📞 Call Support', callback_data: 'call_support' },
            { text: '📧 Email Support', callback_data: 'email_support' }
          ]]
        }
      });

      // Notify support team on Slack
      const slackSender = await this.automation.to('slack');
      await slackSender.send({
        channel: '#support',
        text: `🆘 New support request from ${update.message.from.first_name}`,
        attachments: [{
          color: 'warning',
          fields: [
            { title: 'User', value: update.message.from.username, short: true },
            { title: 'Message', value: update.message.text, short: false }
          ]
        }]
      });
    }

    return { status: 'ok' };
  }
}

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is MIT licensed.

🚀 Roadmap

  • [ ] GraphQL subscription support
  • [ ] Message queuing with Redis
  • [ ] Rate limiting and throttling
  • [ ] Multi-tenant support
  • [ ] Webhook replay functionality
  • [ ] Built-in monitoring dashboard

Developed by Mohammed Mustafa for the NestJS community 🚀