mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2024-12-26 07:48:11 +03:00
931 B
931 B
id | title | sidebar_label | slug |
---|---|---|---|
webhooks | Webhooks | Webhooks | webhooks |
If you want to configure a telegram bot webhook, you need to get a middleware from TelegrafProvider
for connect it in your main.ts
file.
To access it, you must use the app.get()
method, followed by the provider reference:
const telegrafProvider = app.get('TelegrafProvider');
Now you can connect middleware:
app.use(telegrafProvider.webhookCallback('/secret-path'));
The last step is to specify launchOptions in forRoot
method:
TelegrafModule.forRootAsync({
imports: [ConfigModule.forFeature(telegrafModuleConfig)],
useFactory: async (configService: ConfigService) => ({
token: configService.get<string>('TELEGRAM_BOT_TOKEN'),
launchOptions: {
webhook: {
domain: 'domain.tld',
hookPath: '/secret-path',
}
}
}),
inject: [ConfigService],
});