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

@innv/logos-sdk

v0.2.0

Published

SDK NestJS para integração com o Logos Engine — chatbot conversacional SaaS.

Readme

@innv/logos-sdk

SDK NestJS para integração com o Logos Engine — plataforma SaaS de chatbots conversacionais com IA.

Instalação

npm install @innv/logos-sdk @nestjs/axios axios

Quick Start

1. Configurar o módulo

// app.module.ts
import { Module } from '@nestjs/common';
import { LogosModule } from '@innv/logos-sdk';

@Module({
  imports: [
    LogosModule.forRoot({
      apiKey: 'SUA_API_KEY',
      baseUrl: 'https://api.logos-engine.com',
    }),
  ],
})
export class AppModule {}

Configuração assíncrona (ex: ler da env via ConfigService):

import { ConfigModule, ConfigService } from '@nestjs/config';

LogosModule.forRootAsync({
  imports: [ConfigModule],
  useFactory: (config: ConfigService) => ({
    apiKey: config.get('LOGOS_API_KEY'),
    baseUrl: config.get('LOGOS_BASE_URL'),
    webhookSecret: config.get('LOGOS_WEBHOOK_SECRET'),
  }),
  inject: [ConfigService],
}),

2. Enviar mensagens

import { Injectable } from '@nestjs/common';
import { LogosService } from '@innv/logos-sdk';

@Injectable()
export class ChatService {
  constructor(private readonly logos: LogosService) {}

  async handleUserMessage(phone: string, text: string) {
    const response = await this.logos.sendMessage('AGENT_ID', {
      sessionId: phone,
      input: text,
      contactReference: phone,
    });

    console.log(`Mensagem enfileirada: ${response.messageId}`);
  }
}

3. Receber webhooks

import { Body, Controller, Post } from '@nestjs/common';
import { LogosWebhookPayload, LogosBotAction } from '@innv/logos-sdk';

@Controller('webhooks')
export class WebhookController {
  @Post('logos')
  handleWebhook(@Body() payload: LogosWebhookPayload) {
    if (payload.event === 'bot_decision' && payload.decision) {
      switch (payload.decision.action) {
        case LogosBotAction.REPLY:
          // Enviar mensagem de volta ao usuário
          this.sendToUser(payload.sessionId, payload.decision.message!);
          break;

        case LogosBotAction.FINISH:
          // Enviar mensagem final e encerrar sessão
          this.sendToUser(payload.sessionId, payload.decision.message!);
          this.closeSession(payload.sessionId);
          break;

        case LogosBotAction.ESCALATE:
          // Transferir para atendente humano
          this.transferToHuman(payload.sessionId, payload.decision.target!);
          break;
      }
    }
  }
}

API Reference

LogosService

| Método | Descrição | Retorno | |--------|-----------|---------| | sendMessage(agentId, message) | Envia mensagem para processamento | IngestResponse | | getSession(agentId, sessionId) | Consulta estado de uma sessão | SessionResponse | | createAgent(agent) | Cria um chatbot | AgentResponse | | updateAgent(agentId, agent) | Atualiza chatbot | AgentResponse | | getAgent(agentId) | Consulta chatbot | AgentResponse | | listAgents() | Lista todos os chatbots | AgentResponse[] | | deleteAgent(agentId) | Remove chatbot | void |

Verificação de Webhook (HMAC)

import { verifyWebhookSignature } from '@innv/logos-sdk';

const isValid = verifyWebhookSignature(
  rawBody,                    // string ou Buffer do body
  request.headers['x-webhook-signature'],  // header da assinatura
  'seu-webhook-secret',       // secret configurado no agent
);

Ou usando o Guard automático:

import { UseGuards } from '@nestjs/common';
import { LogosWebhookGuard } from '@innv/logos-sdk';

@Post('logos')
@UseGuards(LogosWebhookGuard)
handleWebhook(@Body() payload: LogosWebhookPayload) {
  // A assinatura já foi validada pelo guard
}

Tipos Exportados

import {
  // Configuração
  LogosModuleOptions,
  LogosModuleAsyncOptions,

  // Módulo e Serviço
  LogosModule,
  LogosService,

  // Mensagens
  IngestMessage,
  IngestResponse,

  // Webhooks
  LogosWebhookPayload,
  BotDecision,
  BotDecisionTarget,
  LogosBotAction,

  // Agents
  CreateAgentInput,
  UpdateAgentInput,
  AgentResponse,

  // Sessions
  SessionResponse,

  // Helpers
  verifyWebhookSignature,
  LogosWebhookGuard,
  LogosApiException,
} from '@innv/logos-sdk';

Tratamento de Erros

Todos os métodos do LogosService lançam LogosApiException em caso de erro HTTP:

import { LogosApiException } from '@innv/logos-sdk';

try {
  await this.logos.getAgent('nonexistent-id');
} catch (error) {
  if (error instanceof LogosApiException) {
    console.error(`HTTP ${error.statusCode}: ${error.message}`);
    console.error('Response:', error.responseBody);
  }
}

License

MIT