diff --git a/README.md b/README.md index 63dd768d..b9e2927a 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ If you try to send an image the "echo server" will send a path to the downloaded - `DEBUG` - show debug and verbose logs, set in any value - `WHATSAPP_API_PORT` - listen port for HTTP server (default: `3000`) - `WHATSAPP_API_HOSTNAME` - Hostname for HTTP server (default: `localhost`) +- `WHATSAPP_START_SESSION` - start session with that name right after launching the app ## Webhooks diff --git a/src/config.service.ts b/src/config.service.ts index 35895eff..ff1a4f68 100644 --- a/src/config.service.ts +++ b/src/config.service.ts @@ -46,6 +46,10 @@ export class WhatsappConfigService { return types ? types.split(',') : null } + get startSession(): string | undefined { + return this.configService.get('WHATSAPP_START_SESSION', undefined) + } + get(name: string): any { return this.configService.get(name) } diff --git a/src/whatsapp.service.ts b/src/whatsapp.service.ts index beb7cc1e..ef5a0943 100644 --- a/src/whatsapp.service.ts +++ b/src/whatsapp.service.ts @@ -221,6 +221,9 @@ export class WhatsappSessionManager implements OnApplicationShutdown { this.log.setContext('WhatsappSessionManager') this.cleanDownloadsFolder(this.config.filesFolder) this.sessions = {} + if (config.startSession) { + this.startSession(config.startSession) + } } async startSession(name: string) {