GramJS

messages.SetTyping

Sends a current user typing event (see SendMessageAction for all event types) to a conversation partner or group.

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.SetTyping({
      peer: "username",
      action: new Api.SendMessageTypingAction({}),
      topMsgId: 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.Bool = await client.invoke(
    new Api.messages.SetTyping({
      peer: "username",
      action: new Api.SendMessageTypingAction({}),
      topMsgId: 43,
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
flags#Flags, see TL conditional fields
peerInputPeerTarget user or group
topMsgIdflags.0?intThread ID
actionSendMessageActionType of action
Parameter added in Layer 17.

Result

Bool

Possible errors

CodeTypeDescription
400CHANNEL_INVALIDThe provided channel is invalid
400CHANNEL_PRIVATEYou haven't joined this channel/supergroup
400CHAT_ADMIN_REQUIREDYou must be an admin in this chat to do this
400CHAT_ID_INVALIDThe provided chat id is invalid
403CHAT_WRITE_FORBIDDENYou can't write in this chat
400INPUT_USER_DEACTIVATEDThe specified user was deleted
400MSG_ID_INVALIDInvalid message ID provided
400PEER_ID_INVALIDThe provided peer id is invalid
400USER_BANNED_IN_CHANNELYou're banned from sending messages in supergroups/channels
400USER_IS_BLOCKEDYou were blocked by this user
400USER_IS_BOTBots can't send messages to other bots

Can bots use this method?

Yes

Threads

Telegram allows commenting on a channel post or on a generic supergroup message, thanks to message threads.

Layers

Below you will find information on scheme changes. For more details on the use of layers, see Invoking API methods.

SendMessageAction

User actions. Use this to provide users with detailed info about their chat partners' actions: typing or sending attachments of all kinds.