GramJS

phone.RequestCall

Start a telegram phone call

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.phone.RequestCall({
      userId: "username",
      randomId: 43,
      gAHash: Buffer.from("arbitrary data here"),
      protocol: new Api.PhoneCallProtocol({
        minLayer: 43,
        maxLayer: 43,
        libraryVersions: ["some string here"],
        udpP2p: true,
        udpReflector: true,
      }),
      video: true,
    })
  );
  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.phone.PhoneCall = await client.invoke(
    new Api.phone.RequestCall({
      userId: "username",
      randomId: 43,
      gAHash: Buffer.from("arbitrary data here"),
      protocol: new Api.PhoneCallProtocol({
        minLayer: 43,
        maxLayer: 43,
        libraryVersions: ["some string here"],
        udpP2p: true,
        udpReflector: true,
      }),
      video: true,
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
flags#Flags, see TL conditional fields
videoflags.0?trueWhether to start a video call
userIdInputUserDestination of the phone call
randomIdintRandom ID to avoid resending the same object
gAHashbytesParameter for E2E encryption key exchange ยป
protocolPhoneCallProtocolPhone call settings

Result

phone.PhoneCall

Possible errors

CodeTypeDescription
400CALL_PROTOCOL_FLAGS_INVALIDCall protocol flags invalid
400PARTICIPANT_VERSION_OUTDATEDThe other participant does not use an up to date telegram client with support for calls
400USER_ID_INVALIDThe provided user ID is invalid
403USER_IS_BLOCKEDYou were blocked by this user
403USER_PRIVACY_RESTRICTEDThe user's privacy settings do not allow you to do this

Can bots use this method?

No

End-to-End Encrypted Voice Calls