Telegram Bot 一步一步來安裝步驟

林柏翰
2 min readNov 20, 2020

1. Creating new bot
2. Setting bot
3. 開通設備
4. 連結 Webhook
5. 測試連線
6. 補充相關連結

1. Creating new bot

在 Telegram 好友聯絡人輸入 BotFather
只要加 BotFather 為好友,就可以開始管理你的 Bot

在 機器人之父 聊天室打 /start 後它會親切地問候,列出他提供什麼服務

I can help you create and manage Telegram bots. If you’re new to the Bot API, please see the manual.You can control me by sending these commands:/newbot — create a new bot
/mybots — edit your bots [beta]
Edit Bots
/setname — change a bot’s name
/setdescription — change bot description
/setabouttext — change bot about info
/setuserpic — change bot profile photo
/setcommands — change the list of commands
/deletebot — delete a bot
Bot Settings
/token — generate authorization token
/revoke — revoke bot access token
/setinline — toggle inline mode
/setinlinegeo — toggle inline location requests
/setinlinefeedback — change inline feedback settings
/setjoingroups — can your bot be added to groups?
/setprivacy — toggle privacy mode in groups
Games
/mygames — edit your games [beta]
/newgame — create a new game
/listgames — get a list of your games
/editgame — edit a game
/deletegame — delete an existing game

使用 /new bot 指令,接著輸入 Chatbot name 及 username,
最後就會得到一組 Token

Use this token to access the HTTP API:
123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
Keep your token secure and store it safely, it can be used by anyone to control your bot.

一定要保留你的 Token !!!
一定要保留你的 Token !!!
一定要保留你的 Token !!!
很重要一定要說三次,所有 Telegram Bot API 都會需要它

2. Setting bot

建立完後 Bot 後
在 機器人之父聊天室 /mybots 他會讓你選擇你的機器人

這是時候可以透過他的選單,去設定Bot相關資訊

例如點擊Edit Commands時,他會回復你

OK. Send me a list of commands for your bot. Please use this format:command1 — Description
command2 — Another description
Send /empty to keep the list empty.

這時候如果想要設定多個 Commands 時輸入

testcommand1 — 測試用指令
testcommand2 — 測試用指令2
testcommand3 — 測試用指令3

這樣機器人就會幫你註冊三個 Commands 囉,很方便吧

小提醒

輸入 /empty 會幫你把指令清空喔

--

--