mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
feat: added compatibility with typebot v2
This commit is contained in:
parent
a1d13f8ff3
commit
876320b849
@ -2,6 +2,7 @@
|
||||
|
||||
### Feature
|
||||
* Added AWS SQS Integration
|
||||
* Added compatibility with typebot v2
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -51,6 +51,12 @@ RABBITMQ_URI=amqp://guest:guest@rabbitmq:5672
|
||||
|
||||
WEBSOCKET_ENABLED=false
|
||||
|
||||
SQS_ENABLED=false
|
||||
SQS_ACCESS_KEY_ID=
|
||||
SQS_SECRET_ACCESS_KEY=
|
||||
SQS_ACCOUNT_ID=
|
||||
SQS_REGION=
|
||||
|
||||
# Global Webhook Settings
|
||||
# Each instance's Webhook URL and events will be requested at the time it is created
|
||||
## Define a global webhook that will listen for enabled events from all instances
|
||||
@ -99,6 +105,8 @@ CONFIG_SESSION_PHONE_NAME=Chrome
|
||||
QRCODE_LIMIT=30
|
||||
QRCODE_COLOR=#198754
|
||||
|
||||
TYPEBOT_API_VERSION=v1
|
||||
|
||||
# Defines an authentication type for the api
|
||||
# We recommend using the apikey because it will allow you to use a custom token,
|
||||
# if you use jwt, a random token will be generated and may be expired and you will have to generate a new token
|
||||
|
@ -56,6 +56,12 @@ ENV RABBITMQ_URI=amqp://guest:guest@rabbitmq:5672
|
||||
|
||||
ENV WEBSOCKET_ENABLED=false
|
||||
|
||||
ENV SQS_ENABLED=false
|
||||
ENV SQS_ACCESS_KEY_ID=
|
||||
ENV SQS_SECRET_ACCESS_KEY=
|
||||
ENV SQS_ACCOUNT_ID=
|
||||
ENV SQS_REGION=
|
||||
|
||||
ENV WEBHOOK_GLOBAL_URL=
|
||||
ENV WEBHOOK_GLOBAL_ENABLED=false
|
||||
|
||||
@ -98,6 +104,8 @@ ENV CONFIG_SESSION_PHONE_NAME=Chrome
|
||||
ENV QRCODE_LIMIT=30
|
||||
ENV QRCODE_COLOR=#198754
|
||||
|
||||
ENV TYPEBOT_API_VERSION=v1
|
||||
|
||||
ENV AUTHENTICATION_TYPE=apikey
|
||||
|
||||
ENV AUTHENTICATION_API_KEY=B6D711FCDE4D4FD5936544120E713976
|
||||
|
@ -132,6 +132,7 @@ export type SslConf = { PRIVKEY: string; FULLCHAIN: string };
|
||||
export type Webhook = { GLOBAL?: GlobalWebhook; EVENTS: EventsWebhook };
|
||||
export type ConfigSessionPhone = { CLIENT: string; NAME: string };
|
||||
export type QrCode = { LIMIT: number; COLOR: string };
|
||||
export type Typebot = { API_VERSION: string };
|
||||
export type Production = boolean;
|
||||
|
||||
export interface Env {
|
||||
@ -150,6 +151,7 @@ export interface Env {
|
||||
WEBHOOK: Webhook;
|
||||
CONFIG_SESSION_PHONE: ConfigSessionPhone;
|
||||
QRCODE: QrCode;
|
||||
TYPEBOT: Typebot;
|
||||
AUTHENTICATION: Auth;
|
||||
PRODUCTION?: Production;
|
||||
CHATWOOT?: Chatwoot;
|
||||
@ -305,6 +307,9 @@ export class ConfigService {
|
||||
LIMIT: Number.parseInt(process.env.QRCODE_LIMIT) || 30,
|
||||
COLOR: process.env.QRCODE_COLOR || '#198754',
|
||||
},
|
||||
TYPEBOT: {
|
||||
API_VERSION: process.env?.TYPEBOT_API_VERSION || 'v1',
|
||||
},
|
||||
AUTHENTICATION: {
|
||||
TYPE: process.env.AUTHENTICATION_TYPE as 'apikey',
|
||||
API_KEY: {
|
||||
|
@ -83,6 +83,13 @@ RABBITMQ:
|
||||
ENABLED: false
|
||||
URI: "amqp://guest:guest@localhost:5672"
|
||||
|
||||
SQS:
|
||||
ENABLED: true
|
||||
ACCESS_KEY_ID: ""
|
||||
SECRET_ACCESS_KEY: ""
|
||||
ACCOUNT_ID: ""
|
||||
REGION: "us-east-1"
|
||||
|
||||
WEBSOCKET:
|
||||
ENABLED: false
|
||||
|
||||
@ -139,6 +146,9 @@ QRCODE:
|
||||
LIMIT: 30
|
||||
COLOR: "#198754"
|
||||
|
||||
TYPEBOT:
|
||||
API_VERSION: 'v1' # v1 | v2
|
||||
|
||||
# Defines an authentication type for the api
|
||||
# We recommend using the apikey because it will allow you to use a custom token,
|
||||
# if you use jwt, a random token will be generated and may be expired and you will have to generate a new token
|
||||
|
@ -1,5 +1,6 @@
|
||||
import axios from 'axios';
|
||||
|
||||
import { ConfigService, Typebot } from '../../config/env.config';
|
||||
import { Logger } from '../../config/logger.config';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { Session, TypebotDto } from '../dto/typebot.dto';
|
||||
@ -8,7 +9,7 @@ import { Events } from '../types/wa.types';
|
||||
import { WAMonitoringService } from './monitor.service';
|
||||
|
||||
export class TypebotService {
|
||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||
constructor(private readonly waMonitor: WAMonitoringService, private readonly configService: ConfigService) {}
|
||||
|
||||
private readonly logger = new Logger(TypebotService.name);
|
||||
|
||||
@ -162,7 +163,8 @@ export class TypebotService {
|
||||
};
|
||||
|
||||
try {
|
||||
const request = await axios.post(data.url + '/api/v1/sendMessage', reqData);
|
||||
const version = this.configService.get<Typebot>('TYPEBOT').API_VERSION;
|
||||
const request = await axios.post(`${data.url}/api/${version}/sendMessage`, reqData);
|
||||
|
||||
await this.sendWAMessage(
|
||||
instance,
|
||||
@ -251,7 +253,8 @@ export class TypebotService {
|
||||
};
|
||||
|
||||
try {
|
||||
const request = await axios.post(data.url + '/api/v1/sendMessage', reqData);
|
||||
const version = this.configService.get<Typebot>('TYPEBOT').API_VERSION;
|
||||
const request = await axios.post(`${data.url}/api/${version}/sendMessage`, reqData);
|
||||
|
||||
if (request?.data?.sessionId) {
|
||||
data.sessions.push({
|
||||
@ -554,7 +557,8 @@ export class TypebotService {
|
||||
};
|
||||
|
||||
try {
|
||||
const request = await axios.post(url + '/api/v1/sendMessage', reqData);
|
||||
const version = this.configService.get<Typebot>('TYPEBOT').API_VERSION;
|
||||
const request = await axios.post(`${data.url}/api/${version}/sendMessage`, reqData);
|
||||
|
||||
await this.sendWAMessage(
|
||||
instance,
|
||||
@ -640,7 +644,9 @@ export class TypebotService {
|
||||
|
||||
let request: any;
|
||||
try {
|
||||
request = await axios.post(url + '/api/v1/sendMessage', reqData);
|
||||
const version = this.configService.get<Typebot>('TYPEBOT').API_VERSION;
|
||||
request = await axios.post(`${data.url}/api/${version}/sendMessage`, reqData);
|
||||
|
||||
await this.sendWAMessage(
|
||||
instance,
|
||||
remoteJid,
|
||||
@ -719,7 +725,8 @@ export class TypebotService {
|
||||
sessionId: session.sessionId.split('-')[1],
|
||||
};
|
||||
|
||||
const request = await axios.post(url + '/api/v1/sendMessage', reqData);
|
||||
const version = this.configService.get<Typebot>('TYPEBOT').API_VERSION;
|
||||
const request = await axios.post(`${url}/api/${version}/sendMessage`, reqData);
|
||||
|
||||
await this.sendWAMessage(
|
||||
instance,
|
||||
|
@ -166,7 +166,7 @@ export class WAStartupService {
|
||||
|
||||
private chatwootService = new ChatwootService(waMonitor, this.configService);
|
||||
|
||||
private typebotService = new TypebotService(waMonitor);
|
||||
private typebotService = new TypebotService(waMonitor, this.configService);
|
||||
|
||||
private chamaaiService = new ChamaaiService(waMonitor, this.configService);
|
||||
|
||||
|
@ -102,7 +102,7 @@ export const waMonitor = new WAMonitoringService(eventEmitter, configService, re
|
||||
|
||||
const authService = new AuthService(configService, waMonitor, repository);
|
||||
|
||||
const typebotService = new TypebotService(waMonitor);
|
||||
const typebotService = new TypebotService(waMonitor, configService);
|
||||
|
||||
export const typebotController = new TypebotController(typebotService);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user