@chatbot-kit/nestjs-chat-integration
v0.4.0
Published
NestJS module for Atendimento chat integrations
Downloads
708
Maintainers
Readme
@chatbot-kit/nestjs-chat-integration
NestJS library for integrating applications with Atendimento using standard chat routes.
Installation
npm install @chatbot-kit/nestjs-chat-integration hbs dotenv --savePublishing
The package is published as a public scoped package on npm.
Prerequisites
- npm account with publish permission for the
@chatbot-kitscope - authenticated npm CLI session
Release flow
- Update the package version:
npm version patchUse minor or major instead of patch when appropriate.
- Confirm the package contents:
npm pack --dry-run- Publish to npm:
npm publish --access publicAuthentication
npm login
npm whoamiNotes
prepublishOnlyrunsnpm run buildautomatically beforenpm publish- only compiled files from
dist/are included in the published package - for the first publish of a scoped public package,
--access publicis required
Usage
import { Module } from '@nestjs/common'
import {
ChatIntegrationModule,
IIntegrationService,
} from '@chatbot-kit/nestjs-chat-integration'
class AppService implements IIntegrationService {
async execute(methodName: string, env: string, params: any) {
return { ok: true, data: { methodName, env, params } }
}
async renderPage(page: string, env: string, params: any) {
return { ok: true, page, response: { env, params } }
}
}
@Module({
imports: [
ChatIntegrationModule.forRoot({
integrationService: AppService,
appVersion: '1.0.0',
routePrefix: 'integracao-atendimento',
jwtSecret: process.env.JWT_SECRET || '',
}),
],
providers: [AppService],
})
export class AppModule {}Options
ChatIntegrationModule.forRoot(...) accepts:
integrationService: service class implementingIIntegrationServiceappVersion: application version returned by the version endpointroutePrefix: route prefix used by the generated controller. It must be non-empty and must not contain spaces or repeated slashes.jwtSecret: JWT secret used to validate page tokens. It is required and the module throws during bootstrap if it is empty.
Public API
The package exports:
ChatIntegrationModuleIIntegrationServiceChatIntegrationModuleOptionsExecuteReqDtoExecuteResDtoPageResDtoIntegrationHttpServiceHttpCallResult
Generated routes
If routePrefix is integracao-atendimento, the module exposes:
GET /integracao-atendimento/versionPOST /integracao-atendimento/executeGET /integracao-atendimento/:page/:env/:token
Validation
The module validates configuration during bootstrap and throws when:
jwtSecretis emptyroutePrefixis emptyroutePrefixcontains spacesroutePrefixcontains repeated slashes
