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