messages.GetDialogs
Returns the current user dialog list.
Example
const { Api, TelegramClient } = require("telegram");
const { StringSession } = require("telegram/sessions");
const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});
(async function run() {
await client.connect(); // This assumes you have already authenticated with .start()
const result = await client.invoke(
new Api.messages.GetDialogs({
offsetDate: 43,
offsetId: 43,
offsetPeer: "username",
limit: 100,
hash: BigInt("-4156887774564"),
excludePinned: true,
folderId: 43,
})
);
console.log(result); // prints the result
})();
import { Api, TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";
const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});
(async function run() {
await client.connect(); // This assumes you have already authenticated with .start()
const result: Api.messages.Dialogs = await client.invoke(
new Api.messages.GetDialogs({
offsetDate: 43,
offsetId: 43,
offsetPeer: "username",
limit: 100,
hash: BigInt("-4156887774564"),
excludePinned: true,
folderId: 43,
})
);
console.log(result); // prints the result
})();
Parameters
Name | Type | Description |
---|---|---|
flags | # | Flags, see TL conditional fields |
excludePinned | flags.0?true | Exclude pinned dialogs |
folderId | flags.1?int | Peer folder ID, for more info click here |
offsetDate | int | Offsets for pagination, for more info click here |
offsetId | int | Offsets for pagination, for more info click here |
offsetPeer | InputPeer | Offset peer for pagination |
limit | int | Number of list elements to be returned |
hash | long | Hash for pagination, for more info click here |
Result
Possible errors
Code | Type | Description |
---|---|---|
400 | FOLDER_ID_INVALID | Invalid folder ID. |
400 | OFFSET_PEER_ID_INVALID | The provided offset peer is invalid. |
Can bots use this method?
No
Related pages
Folders
Telegram allows placing chats into folders, based on their type, mute status, or other custom criteria, thanks to folder blacklists and whitelists.
Pagination in the API
How to fetch results from large lists of objects.