NEW 📢 Limited launch offer: up to 70% off your first month on every game!See plans

How to host a Telegram, Twitch, Slack or Matrix bot

Discord bot hostingUpdated Oct 29, 20265 min read

A bot plan runs more than Discord bots. For Telegram, choose Telegram when the order asks What is your bot for?: the Bot page then has a Telegram pane for the token from @BotFather. For Twitch, Slack or Matrix, choose Another platform and put your keys under Environment. Either way, use your library's polling or socket mode, because a bot server has no public web address to receive webhooks. Telegram step by step: How to host a Telegram bot.

Only want to relay messages between Discord and Telegram, Matrix or Slack, without writing code? Use the ready-made matterbridge type: How to link Discord with Telegram, Matrix or Slack with matterbridge.

Which mode to use

PlatformUseNot
TelegramLong polling (for example run_polling() in python-telegram-bot, bot.start() in grammY)Webhooks
SlackSocket Mode, with an app-level tokenRequest URLs (HTTP events)
Twitch chatA chat library that connects out to Twitch (IRC or EventSub over WebSocket)EventSub webhooks
MatrixA client library that syncs with your homeserverAn application service that needs an inbound URL

All of these connect out from your server, so nothing has to reach in.

Set it up

  1. Open your server in the panel. Check the type on the bot's card on Overview is the language of your code, for example Node.js Bot or Python Bot; change it if needed: How to switch your bot to another language.
  2. Ordered for Telegram or another platform? This is already done. If your bot is set up for Discord, in the Set up your bot card on Overview, after Set it up for:, click Telegram or Another platform and confirm with Switch. The same choice is on the Bot page, pane Discord, card What is this bot for?.
  3. Upload your code in Files, with package.json or requirements.txt. See How to upload your Discord bot code.
  4. On the Bot page, pane Code, set Entry file.
  5. Telegram: on the pane Telegram, paste the token from @BotFather and click Connect. Your code reads it as TELEGRAM_BOT_TOKEN, BOT_TOKEN, TOKEN, TELEGRAM_TOKEN or TELOXIDE_TOKEN. Twitch, Slack or Matrix: on the pane Environment, add your tokens as variables, for example SLACK_APP_TOKEN and SLACK_BOT_TOKEN. Names ending in TOKEN are kept secret automatically. On a bot set up for another platform, TOKEN and BOT_TOKEN are yours to use; only DISCORD_TOKEN is reserved. On a bot still set up for Discord, TOKEN, BOT_TOKEN and DISCORD_BOT_TOKEN are reserved for the Discord token.
  6. Press Start (top right on a computer, at the bottom of the screen on a phone) and read Console.

The Environment variables card with three variables, one marked Secret and shown as dots, and the Add a variable form below.

A minimal Telegram bot (Python)

requirements.txt

python-telegram-bot

bot.py

import os

from telegram import Update
from telegram.ext import Application, CommandHandler, ContextTypes


async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
    await update.message.reply_text("Hello! I am running on PlayNHost.")


app = Application.builder().token(os.environ["TELEGRAM_BOT_TOKEN"]).build()
app.add_handler(CommandHandler("start", start))
print("Bot started, polling for updates")
app.run_polling()

The Discord parts of the panel

A bot is set up for one platform at a time, and the panel follows that choice:

  • On a bot set up for Discord, the Set up your bot card on Overview opens on Connect to Discord. Under the token field it says Running a Telegram, Twitch, Slack or Matrix bot? It needs no Discord token. Set it up for: with Telegram and Another platform. The choice is saved on the server, so it holds in every browser. Switching deletes nothing: a token saved for the other platform stays saved and comes back if you switch back.
  • Set up for Telegram, the Bot page has the panes Telegram, Code, Environment and Restarts: no intents and no invite link. Set up for another platform, it has Code, Environment and Restarts.
  • The chip on Overview reads Running while your bot runs. When the console shows a ready line such as Logged in as @your_bot, it turns to Online in Telegram on a Telegram bot and Online on another platform. Online in Discord is only for Discord logins.

The Connect to Discord step of the Set up your bot card with the line Running a Telegram, Twitch, Slack or Matrix bot? It needs no Discord token. Set it up for: and the Telegram and Another platform links.

Everything else works the same: packages install when you change them, a crashed bot is started again, and you can schedule restarts in Quick Tasks. See How to use the Bot page of your Discord bot.

Already hosting your bot somewhere else? Move it to us

OUR LATEST BLOGS