How to Create a Telegram Bot & Set Up a Contact Form — Complete Guide

DOCUMENTATION v1.0

Telegram Bot Setup Guide

Create bot  //  Get tokens  //  Find IDs  //  Deploy form

01

How to Create a Telegram Bot

All Telegram bots are created and managed through @BotFather — the official Telegram bot that controls all other bots. Follow the steps below.

STEP 01 Open Telegram and find BotFather

Open Telegram on any device (mobile or desktop). In the search bar, type @BotFather and tap on the result. Make sure it has a blue verified checkmark.

Alternatively, open this link directly in Telegram:

LINK
https://t.me/BotFather
STEP 02 Start BotFather and send /newbot

Press START if you haven't used BotFather before. Then send the command:

COMMAND
/newbot

BotFather will reply asking for the bot's display name (can contain spaces, e.g. My Contact Bot).

STEP 03 Choose a username for the bot

After setting the name, BotFather will ask for a username. This must:

└ End in bot (e.g. mycontact_bot or MyContactBot)

└ Be unique — no other bot can have this username

└ Contain only letters, digits, and underscores

STEP 04 Bot created — token is displayed

BotFather will confirm your bot is created and display a bot token. Copy it and keep it safe — you will need it in the next section.

Never share your bot token publicly. Anyone with the token can control your bot and read all messages it receives.
02

How to Get Your Bot Token

FORMAT What a bot token looks like

A bot token is a string in this exact format:

TOKEN FORMAT
1234567890:AAEz3FI9ypvMdtTzzl4NdzymT2AEG2tNByc // ↑ Bot ID ↑ Secret hash (35 characters)
RETRIEVE How to retrieve an existing token

If you lost your token, go to @BotFather, send /mybots, select your bot, then tap API Token.

COMMANDS
/mybots → Select your bot from the list → Click "API Token" → Copy the token shown
REVOKE How to reset / revoke a compromised token

If your token is leaked, immediately revoke it via BotFather:

COMMANDS
/mybots → Select your bot → "API Token" → "Revoke current token"

A new token will be generated. Update it in your form code immediately.

Using the token in code: In the contact form, replace the TOKEN variable with your actual token string. Keep it inside single quotes.
JAVASCRIPT — WHERE TO PUT YOUR TOKEN
var TOKEN = '7449425339:AAH7V_P5sIMpE5owPr2Uec-AYkLXgcjNKYE'; ↑ Replace this entire string with your bot token
03

How to Get Your Telegram User ID

Your personal Telegram user ID is a permanent numeric identifier for your account. It never changes, even if you change your username or phone number.

METHOD 1 Use @userinfobot (easiest)

Open Telegram and search for @userinfobot. Send any message (e.g. /start) and it will instantly reply with your user ID and other account info.

DIRECT LINK
https://t.me/userinfobot
EXAMPLE REPLY
Id: 1958371619 First: John Last: Doe Username: @johndoe Language: en

The number next to Id: is your personal user ID.

METHOD 2 Use the Telegram API directly

Send a message to your bot, then call this URL in any browser (replace TOKEN with your bot token):

BROWSER URL
https://api.telegram.org/botYOUR_TOKEN/getUpdates

Find message.from.id in the JSON response — that is your user ID.

JSON RESPONSE (truncated)
{ "message": { "from": { "id": 1958371619, ← YOUR USER ID "first_name": "John", "username": "johndoe" } } }
Important: Before calling getUpdates via browser, send at least one message to your bot first, otherwise the updates array will be empty.
04

How to Get a Telegram Group ID

Group IDs are always negative numbers and begin with -100 for supergroups and channels. Regular groups start with just -.

STEP 01 Add your bot to the group

Open the group in Telegram. Tap the group name at the top → Add Members → search for your bot by its @username → Add it.

The bot must be a member of the group to send messages to it. For channels, the bot must be an Administrator.
STEP 02 Send a message in the group

Send any message in the group (you can delete it later). This is required so the API has something to return in the next step.

STEP 03 Call getUpdates to find the group ID

Paste this URL in your browser (replace with your token):

BROWSER URL
https://api.telegram.org/botYOUR_TOKEN/getUpdates

Look for message.chat.id in the response — the negative number is your group ID:

JSON RESPONSE (truncated)
{ "message": { "chat": { "id": -1003838567224, ← GROUP ID "title": "My Contact Group", "type": "supergroup" } } }
ALT METHOD Use @getidsbot (quick alternative)

Add @getidsbot to your group. It will automatically post the group ID as soon as it joins. You can remove it afterwards.

DIRECT LINK
https://t.me/getidsbot
05

How to Deploy the Contact Form

BLOGGER Adding the form to a Blogger post or page

In your Blogger post editor, switch from Compose mode to HTML mode (pencil icon → HTML). Paste the entire form code there and publish.

CONFIGURATION LINES TO CHANGE
var TOKEN = 'YOUR_BOT_TOKEN_HERE'; var TARGETS = ['-YOUR_GROUP_ID', 'YOUR_PERSONAL_ID'];
GADGET Adding via Blogger HTML/JavaScript Gadget

Go to Layout in Blogger dashboard → Add a Gadget → choose HTML/JavaScript. Paste the form code and save.

This method places the form in your sidebar or a page section instead of inside a post.
TEST How to verify it is working

After deploying, fill in the form and submit. Within seconds you should receive a message in:

GROUP -1003838567224

PERSONAL DM 1958371619

If no message arrives, open your browser console (F12 → Console) and check for error messages beginning with [TG-REST].

06

Quick Reference Table

WHAT WHERE TO GET IT FORMAT / EXAMPLE
Bot Token @BotFather → /newbot or /mybots → API Token 1234567890:AABBccDD...
Personal User ID @userinfobot → send any message → read Id field 1958371619 (positive integer)
Group ID Add bot to group → getUpdates → chat.id -1003838567224 (negative)
Channel ID @getidsbot → add to channel -100xxxxxxxxxx (negative)
API ENDPOINT WHAT IT DOES
/sendMessage Sends a text message to a chat_id
/sendDocument Sends a file attachment to a chat_id
/getUpdates Retrieves incoming messages (used to find IDs)
/getMe Returns basic info about the bot (verify token works)
7449425339:AAH7V_P5sIMpE5...
-1003838567224
1958371619
+2349076129380
API Base URL: All Telegram Bot API calls start with https://api.telegram.org/bot{TOKEN}/ followed by the method name.

Post a Comment