diff --git a/Docker/.env.example b/Docker/.env.example index ef70e704..847f6ef1 100644 --- a/Docker/.env.example +++ b/Docker/.env.example @@ -88,6 +88,7 @@ WEBHOOK_EVENTS_TYPEBOT_CHANGE_STATUS=false WEBHOOK_EVENTS_CHAMA_AI_ACTION=false # This event is used to send errors WEBHOOK_EVENTS_ERRORS=false +WEBHOOK_EVENTS_ERRORS_WEBHOOK= # Name that will be displayed on smartphone connection CONFIG_SESSION_PHONE_CLIENT=EvolutionAPI diff --git a/Dockerfile b/Dockerfile index 76699acb..6959ea30 100644 --- a/Dockerfile +++ b/Dockerfile @@ -90,6 +90,7 @@ ENV WEBHOOK_EVENTS_TYPEBOT_CHANGE_STATUS=false ENV WEBHOOK_EVENTS_CHAMA_AI_ACTION=false ENV WEBHOOK_EVENTS_ERRORS=false +ENV WEBHOOK_EVENTS_ERRORS_WEBHOOK= ENV CONFIG_SESSION_PHONE_CLIENT=EvolutionAPI ENV CONFIG_SESSION_PHONE_NAME=chrome diff --git a/src/config/env.config.ts b/src/config/env.config.ts index fb566eaf..94f67a7f 100644 --- a/src/config/env.config.ts +++ b/src/config/env.config.ts @@ -96,6 +96,7 @@ export type EventsWebhook = { TYPEBOT_CHANGE_STATUS: boolean; CHAMA_AI_ACTION: boolean; ERRORS: boolean; + ERRORS_WEBHOOK: string; }; export type ApiKey = { KEY: string }; @@ -272,6 +273,7 @@ export class ConfigService { TYPEBOT_CHANGE_STATUS: process.env?.WEBHOOK_EVENTS_TYPEBOT_CHANGE_STATUS === 'true', CHAMA_AI_ACTION: process.env?.WEBHOOK_EVENTS_CHAMA_AI_ACTION === 'true', ERRORS: process.env?.WEBHOOK_EVENTS_ERRORS === 'true', + ERRORS_WEBHOOK: process.env?.WEBHOOK_EVENTS_ERRORS_WEBHOOK || '', }, }, CONFIG_SESSION_PHONE: { diff --git a/src/dev-env.yml b/src/dev-env.yml index 624137e7..7f686cb1 100644 --- a/src/dev-env.yml +++ b/src/dev-env.yml @@ -127,6 +127,7 @@ WEBHOOK: CHAMA_AI_ACTION: false # This event is used to send errors to the webhook ERRORS: false + ERRORS_WEBHOOK: CONFIG_SESSION_PHONE: # Name that will be displayed on smartphone connection diff --git a/src/main.ts b/src/main.ts index 5727575c..167909b1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -57,7 +57,7 @@ function bootstrap() { if (err) { const webhook = configService.get('WEBHOOK'); - if (webhook.GLOBAL.ENABLED && webhook.EVENTS.ERRORS) { + if (webhook.EVENTS.ERRORS_WEBHOOK && webhook.EVENTS.ERRORS_WEBHOOK != '' && webhook.EVENTS.ERRORS) { const tzoffset = new Date().getTimezoneOffset() * 60000; //offset in milliseconds const localISOTime = new Date(Date.now() - tzoffset).toISOString(); const now = localISOTime; @@ -77,7 +77,7 @@ function bootstrap() { logger.error(errorData); - const baseURL = configService.get('WEBHOOK').GLOBAL.URL; + const baseURL = webhook.EVENTS.ERRORS_WEBHOOK; const httpService = axios.create({ baseURL }); httpService.post('', errorData);