GramJS

โš ๏ธ This project is archived and no longer maintained. Development continues in teleproto, an actively maintained fork. It's largely compatible with GramJS for most projects, migration means little more than swapping the package:
npm install teleproto
See the migration guide for details.

phone.AcceptCall

Accept incoming 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.AcceptCall({
      peer: new Api.InputPhoneCall({
        id: BigInt("-4156887774564"),
        accessHash: BigInt("-4156887774564"),
      }),
      gB: Buffer.from("arbitrary data here"),
      protocol: new Api.PhoneCallProtocol({
        minLayer: 43,
        maxLayer: 43,
        libraryVersions: ["some string here"],
        udpP2p: true,
        udpReflector: 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.AcceptCall({
      peer: new Api.InputPhoneCall({
        id: BigInt("-4156887774564"),
        accessHash: BigInt("-4156887774564"),
      }),
      gB: Buffer.from("arbitrary data here"),
      protocol: new Api.PhoneCallProtocol({
        minLayer: 43,
        maxLayer: 43,
        libraryVersions: ["some string here"],
        udpP2p: true,
        udpReflector: true,
      }),
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
peerInputPhoneCallThe call to accept
gBbytesParameter for E2E encryption key exchange ยป
protocolPhoneCallProtocolPhone call settings

Result

phone.PhoneCall

Possible errors

CodeTypeDescription
400CALL_ALREADY_ACCEPTEDThe call was already accepted.
400CALL_ALREADY_DECLINEDThe call was already declined.
500CALL_OCCUPY_FAILEDThe call failed because the user is already making another call.
400CALL_PEER_INVALIDThe provided call peer object is invalid.
400CALL_PROTOCOL_FLAGS_INVALIDCall protocol flags invalid.

Can bots use this method?

No

End-to-End Encrypted Voice Calls