getUserPersonalChatMessages
Gets latest messages from a user personal chat (Bot API 10.0).
Returns: On success, returns Array of Message.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | Integer | Yes | User ID |
limit | Integer | Yes | Max messages count (1-20) |
Example request
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/getUserPersonalChatMessages" \
-H "Content-Type: application/json" \
-d '{"user_id":123456789,"limit":10}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/getUserPersonalChatMessages",
json={
"user_id": 123456789,
"limit": 10
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/getUserPersonalChatMessages`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"user_id": 123456789,
"limit": 10
}),
});
console.log(await res.json());
Step-by-step guide: How to Create a Telegram Bot: Step by Step with BotFather and Python
Related methods
getChatGets chat information.getChatMemberGets chat member information.getChatMemberCountReturns the number of chat members.getChatAdministratorsReturns a list of chat administrators.setChatTitleSets chat title.setChatDescriptionSets chat description.setChatPhotoSets chat photo.deleteChatPhotoDeletes chat photo.setChatPermissionsSets chat permissions.leaveChatLeaves a chat.exportChatInviteLinkExports the main chat invite link.createChatInviteLinkCreates an invite link.