GramJS

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

NameTypeDescription
flags#Flags, see TL conditional fields
excludePinnedflags.0?trueExclude pinned dialogs
folderIdflags.1?intPeer folder ID, for more info click here
offsetDateintOffsets for pagination, for more info click here
offsetIdintOffsets for pagination, for more info click here
offsetPeerInputPeerOffset peer for pagination
limitintNumber of list elements to be returned
hashlongHash for pagination, for more info click here

Result

messages.Dialogs

Possible errors

CodeTypeDescription
400FOLDER_ID_INVALIDInvalid folder ID.
400OFFSET_PEER_ID_INVALIDThe provided offset peer is invalid.

Can bots use this method?

No

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.