mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 12:12:55 -06:00
Added webhook to send errors
This commit is contained in:
parent
9b72b3e332
commit
54cfa67d52
@ -88,6 +88,7 @@ WEBHOOK_EVENTS_TYPEBOT_CHANGE_STATUS=false
|
|||||||
WEBHOOK_EVENTS_CHAMA_AI_ACTION=false
|
WEBHOOK_EVENTS_CHAMA_AI_ACTION=false
|
||||||
# This event is used to send errors
|
# This event is used to send errors
|
||||||
WEBHOOK_EVENTS_ERRORS=false
|
WEBHOOK_EVENTS_ERRORS=false
|
||||||
|
WEBHOOK_EVENTS_ERRORS_WEBHOOK=
|
||||||
|
|
||||||
# Name that will be displayed on smartphone connection
|
# Name that will be displayed on smartphone connection
|
||||||
CONFIG_SESSION_PHONE_CLIENT=EvolutionAPI
|
CONFIG_SESSION_PHONE_CLIENT=EvolutionAPI
|
||||||
|
@ -90,6 +90,7 @@ ENV WEBHOOK_EVENTS_TYPEBOT_CHANGE_STATUS=false
|
|||||||
ENV WEBHOOK_EVENTS_CHAMA_AI_ACTION=false
|
ENV WEBHOOK_EVENTS_CHAMA_AI_ACTION=false
|
||||||
|
|
||||||
ENV WEBHOOK_EVENTS_ERRORS=false
|
ENV WEBHOOK_EVENTS_ERRORS=false
|
||||||
|
ENV WEBHOOK_EVENTS_ERRORS_WEBHOOK=
|
||||||
|
|
||||||
ENV CONFIG_SESSION_PHONE_CLIENT=EvolutionAPI
|
ENV CONFIG_SESSION_PHONE_CLIENT=EvolutionAPI
|
||||||
ENV CONFIG_SESSION_PHONE_NAME=chrome
|
ENV CONFIG_SESSION_PHONE_NAME=chrome
|
||||||
|
@ -96,6 +96,7 @@ export type EventsWebhook = {
|
|||||||
TYPEBOT_CHANGE_STATUS: boolean;
|
TYPEBOT_CHANGE_STATUS: boolean;
|
||||||
CHAMA_AI_ACTION: boolean;
|
CHAMA_AI_ACTION: boolean;
|
||||||
ERRORS: boolean;
|
ERRORS: boolean;
|
||||||
|
ERRORS_WEBHOOK: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ApiKey = { KEY: string };
|
export type ApiKey = { KEY: string };
|
||||||
@ -272,6 +273,7 @@ export class ConfigService {
|
|||||||
TYPEBOT_CHANGE_STATUS: process.env?.WEBHOOK_EVENTS_TYPEBOT_CHANGE_STATUS === 'true',
|
TYPEBOT_CHANGE_STATUS: process.env?.WEBHOOK_EVENTS_TYPEBOT_CHANGE_STATUS === 'true',
|
||||||
CHAMA_AI_ACTION: process.env?.WEBHOOK_EVENTS_CHAMA_AI_ACTION === 'true',
|
CHAMA_AI_ACTION: process.env?.WEBHOOK_EVENTS_CHAMA_AI_ACTION === 'true',
|
||||||
ERRORS: process.env?.WEBHOOK_EVENTS_ERRORS === 'true',
|
ERRORS: process.env?.WEBHOOK_EVENTS_ERRORS === 'true',
|
||||||
|
ERRORS_WEBHOOK: process.env?.WEBHOOK_EVENTS_ERRORS_WEBHOOK || '',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CONFIG_SESSION_PHONE: {
|
CONFIG_SESSION_PHONE: {
|
||||||
|
@ -127,6 +127,7 @@ WEBHOOK:
|
|||||||
CHAMA_AI_ACTION: false
|
CHAMA_AI_ACTION: false
|
||||||
# This event is used to send errors to the webhook
|
# This event is used to send errors to the webhook
|
||||||
ERRORS: false
|
ERRORS: false
|
||||||
|
ERRORS_WEBHOOK: <url>
|
||||||
|
|
||||||
CONFIG_SESSION_PHONE:
|
CONFIG_SESSION_PHONE:
|
||||||
# Name that will be displayed on smartphone connection
|
# Name that will be displayed on smartphone connection
|
||||||
|
@ -57,7 +57,7 @@ function bootstrap() {
|
|||||||
if (err) {
|
if (err) {
|
||||||
const webhook = configService.get<Webhook>('WEBHOOK');
|
const webhook = configService.get<Webhook>('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 tzoffset = new Date().getTimezoneOffset() * 60000; //offset in milliseconds
|
||||||
const localISOTime = new Date(Date.now() - tzoffset).toISOString();
|
const localISOTime = new Date(Date.now() - tzoffset).toISOString();
|
||||||
const now = localISOTime;
|
const now = localISOTime;
|
||||||
@ -77,7 +77,7 @@ function bootstrap() {
|
|||||||
|
|
||||||
logger.error(errorData);
|
logger.error(errorData);
|
||||||
|
|
||||||
const baseURL = configService.get<Webhook>('WEBHOOK').GLOBAL.URL;
|
const baseURL = webhook.EVENTS.ERRORS_WEBHOOK;
|
||||||
const httpService = axios.create({ baseURL });
|
const httpService = axios.create({ baseURL });
|
||||||
|
|
||||||
httpService.post('', errorData);
|
httpService.post('', errorData);
|
||||||
|
Loading…
Reference in New Issue
Block a user