Telegram Bot API

setMySettings

Danh mục: Thông tin bot · Bot API 10.5 · Tài liệu chính thức

Lịch sử phiên bản: Được thêm trong Bot API 10.5

Thay đổi cài đặt bot: chế độ inline, quyền riêng tư, nhóm, chủ đề, chế độ truy vấn callback (Bot API 10.5).

Giá trị trả về: Nếu thành công, trả về True.

Tham số

Tham sốKiểuBắt buộcMô tả
supports_inline_queriesBooleanTùy chọnBật (true) hoặc tắt (false) chế độ inline
inline_query_placeholderStringTùy chọnVăn bản gợi ý của truy vấn inline trong ô nhập (chuỗi rỗng = default)
needs_inline_query_locationBooleanTùy chọnYêu cầu vị trí người dùng với mỗi truy vấn inline
inline_feedback_share_denominatorIntegerTùy chọnTỷ lệ kết quả inline được chọn nhận về: 1 trên N (1, 10, 100, 1000; 0 = không nhận)
can_join_groupsBooleanTùy chọnCho phép thêm bot vào nhóm
can_read_all_group_messagesBooleanTùy chọntrue = tắt chế độ riêng tư (đọc mọi tin nhắn trong nhóm)
can_connect_to_businessBooleanTùy chọnCho phép kết nối bot với tài khoản doanh nghiệp
can_manage_botsBooleanTùy chọnCho phép bot tạo bot được quản lý
supports_guest_queriesBooleanTùy chọnCho phép truy vấn khách từ các chat mà bot không phải thành viên
supports_join_request_queriesBooleanTùy chọnCho phép chỉ định bot xử lý yêu cầu tham gia
has_topics_enabledBooleanTùy chọnBật chế độ chủ đề diễn đàn trong chat riêng với bot
allows_users_to_create_topicsBooleanTùy chọnCho phép người dùng tạo và xóa chủ đề trong chat riêng
has_topic_sidebarBooleanTùy chọnHiển thị chủ đề chat riêng ở thanh bên (Bot API 10.5)
can_communicate_with_botsBooleanTùy chọnCho phép bot giao tiếp với các bot khác
callback_query_modeStringTùy chọnChế độ truy vấn callback: default, auto hoặc inline (inline_message_id thay cho message)

Mô tả tham số chỉ là bản tóm tắt ngắn gọn; xem tài liệu chính thức để đọc toàn văn.

Ví dụ request

curl

curl -s -X POST "https://api.telegram.org/bot$TOKEN/setMySettings" \
  -H "Content-Type: application/json" \
  -d '{
  "supports_inline_queries": true,
  "can_read_all_group_messages": false,
  "callback_query_mode": "auto"
}'

Python

import requests

TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
    f"https://api.telegram.org/bot{TOKEN}/setMySettings",
    json={
        "supports_inline_queries": True,
        "can_read_all_group_messages": False,
        "callback_query_mode": "auto"
    },
    timeout=30,
)
print(resp.json())

JavaScript

const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/setMySettings`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "supports_inline_queries": true,
    "can_read_all_group_messages": false,
    "callback_query_mode": "auto"
  }),
});
console.log(await res.json());

Hướng dẫn từng bước: Cách tạo bot Telegram từ A đến Z: BotFather, token và tin nhắn đầu tiên