I need help with setting up a domain URL for my Telegram bot through code instead of doing it manually. Right now I have to go to BotFather and use the /setdomain
command to pick my bot and enter the URL I want to use.
I already have my bot token and can use other Telegram APIs without problems. But I want to know if there’s an API endpoint that lets me set the domain URL automatically. This would make my setup process much easier since I wouldn’t have to do it by hand every time.
Has anyone found a way to do this programmatically?
Hit this same problem building my deployment pipeline last month. BotFather locks domain config behind manual approval - no way to automate it through the Bot API. I added a step in my CI/CD that pauses deployment and pings me to handle the BotFather setup manually. Not pretty, but it works. You could use webhook URLs instead of custom domains if that works for you - those can be set with setWebhook. Pretty sure Telegram does this to stop automated spam bot creation.
yup, totally get that frustration! unfort, you’ll still have to use BotFather for domain stuff. would be great if they had an API for it, but i guess they want to keep it all secure.
I’ve been working with Telegram bots for years and hit this same wall. There’s no API endpoint for configuring domain URLs - you’re stuck using BotFather’s chat interface. It’s probably a security thing. Telegram wants tight control over domain configs to stop automated abuse and prevent unauthorized changes to bot settings. Since domains affect webhook delivery and bot access, the manual BotFather process acts like an extra security gate. For production, I just document the BotFather steps in my deployment guides. Not ideal for fully automated setups, but it works.