Giới thiệu Bot Telegram? Bot Telegram là một tính năng của telegram giống như một robot để thực hiện một công việc nào đó như nhận tin tức, thông báo, tạo các tuỳ chỉnh hoặc một số lĩnh vực, dịch vụ khác…Theo đó, việc sử dụng bot có thể được ứng dụng để check đơn hàng, ra lệnh thông qua telegram. Do vậy, nếu ứng dụng được bot thì có khá nhiều điều hữu ích. Học Khôn cũng mới tìm tòi về nội dung liên quan tới Bot Telegram. Do vậy, nếu có thắc mắc hoặc trao đổi các bạn có thể gợi ý cho Học Khôn nhé!
Cách tạo Bot Telegram? Để tạo Bot Telegram các bạn thực hiện các bước sau:
– Mở Telegram vào tìm kiếm chọn BotFather và chọn mục có tích xanh, sau đó giao diện Botfather sẽ có những lệnh tương ứng cho các bạn và hướng dẫn bằng tiếng anh. Tại đây các bạn chọn theo hướng dẫn để tạo Bot cá nhân của mình
I can help you create and manage Telegram bots. If you’re new to the Bot API, please see the manual (https://core.telegram.org/bots).
You can control me by sending these commands:
/newbot – create a new bot
/mybots – edit your botsEdit 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 botBot Settings
/token – generate authorization token
/revoke – revoke bot access token
/setinline – toggle inline mode (https://core.telegram.org/bots/inline)
/setinlinegeo – toggle inline location requests (https://core.telegram.org/bots/inline#location-based-results)
/setinlinefeedback – change inline feedback (https://core.telegram.org/bots/inline#collecting-feedback) settings
/setjoingroups – can your bot be added to groups?
/setprivacy – toggle privacy mode (https://core.telegram.org/bots/features#privacy-mode) in groupsWeb Apps
/myapps – edit your web apps (https://core.telegram.org/bots/webapps)
/newapp – create a new web app (https://core.telegram.org/bots/webapps)
/listapps – get a list of your web apps
/editapp – edit a web app
/deleteapp – delete an existing web appGames
/mygames – edit your games (https://core.telegram.org/bots/games)
/newgame – create a new game (https://core.telegram.org/bots/games)
/listgames – get a list of your games
/editgame – edit a game
/deletegame – delete an existing game
Lưu ý: Tên bot phải kết thúc bằng chữ “bot”, ví dụ như hockhonbot hoặc hockhon_bot.
Quản lý Bot Telegram? Sau khi hoàn thiện Bot thì tới bước quản lý, các bạn chọn /mybots để thực hiện một số quản lý cơ bản như tên bot, mô tả, hình ảnh hoặc các lệnh.
Cách lấy API của Bot Telegram: Gõ lệnh /token trên Botfather sau đó Botfather sẽ cung cấp API để sử dụng.
Cách lấy ID Group Telegram: Truy cập trang web chat của Telegram: web.telegram.org, sau đó đăng nhập tài khoản Telegram của bạn. Mở group telegram mà bạn cần tìm ID. Nhìn lên đường link group bạn sẽ thấy được các con số ở đường link https://web.telegram.org/k/#-158949xxxx. Đây chính là mã ID group mà bạn cần tìm.
Cách lấy ID tài khoản Telegram: Tìm GetIDs Bot và chọn start sẽ có ID tài khoản cá nhân.
Kết nối bot Telegram với n8n
Bước 1: Tạo workflow và thêm node “On Messenge” của Telegram Trigger. Tạo Credential và lấy Access Token của bot bằng lệnh /token tại botfather trên telegram. Chọn Test Step để lấy các thông tin khi có tin nhắn đến.
Bước 2: Thêm node “AI Agent“tại đây sẽ có 3 mục gồm Chat Model, Memory, Tool
– Lấy API AI: Gemini là một trong những mô hình AI do Google phát triển, được cung cấp thông qua Google Cloud AI. Để lấy API, truy cập Chat Model Gemini vào https://aistudio.google.com/app/apikey để lấy API cho Gemini. ChatGPT được cung cấp API thông qua OpenAI. Dưới đây là cách lấy API từ OpenAI: Đăng nhập vào trang lấy API của OpenAI và chọn Create New Secret Key để tạo API mới. Lưu ý: API không thể xem lại được nên nếu muốn dùng lại.
– Lấy API của Google Sheets: Tạo Credential của Google Sheets và chọn Service Account. Sau đó truy cập Google Console > IAM & Admin > Service Account > Create Service Account để lấy Email và Private Key cho Node. Nhớ bật Google Sheets API và Google Drive API để n8n có thể truy cập Sheets. Tại bảng tính Google Sheets bật chia sẻ và nhập email tại phần Service Account để n8n xem và đọc nội dung.
Bước 3: Tạo node Telegram > Send a text message để gửi tin nhắn cho người gửi tìm chatbot rose và nhập /id để lấy ID
