startWebhookDev method

Future<void> startWebhookDev(
  1. String ngrokUrl, {
  2. int port = 8080,
  3. String webhookPath = '/webhook',
})

Starts the bot with webhook for ngrok development.

This is a convenience method for local development with ngrok. It automatically configures sensible defaults for development.

Parameters:

  • ngrokUrl: Your ngrok URL (e.g., 'https://abc123.ngrok.io')
  • port: Local port to run on (default: 8080)
  • webhookPath: Webhook path (default: '/webhook')

Example:

// Start ngrok: ngrok http 8080
// Copy the HTTPS URL

final bot = Bot<Context>('YOUR_BOT_TOKEN');

bot.command('start', (ctx) async {
  await ctx.reply('Hello from ngrok! 🚀');
});

await bot.startWebhookDev('https://abc123.ngrok.io');

Implementation

Future<void> startWebhookDev(
  String ngrokUrl, {
  int port = 8080,
  String webhookPath = '/webhook',
}) async {
  await startWebhook(
    webhookUrl: '$ngrokUrl$webhookPath',
    port: port,
    webhookPath: webhookPath,
    corsEnabled: true,
    dropPendingUpdates: true,
    healthCheckPath: '/health',
  );
}