Skip to content

Message sending guidelines#

Beta version

The functionality is in beta. Features may change and may also work unstably.

The recommended way of sending messages is sending by the Chat identifier.

Save the Chat identifier in your database to use this value for further message sending.

If the chat identifier is unknown, first use the CheckAccount method, get the chatId value, and then use the chatId in the message sending methods SendMessage and others.

Sending by username

If the numeric identifier is unknown, you may specify the contact's username with the @ prefix in chatId of the message sending methods SendMessage and others.

However, the owner of the account can change the username at any moment, so it is not suitable for long-term storage.

If an account with such a username does not exist, a notification with the noAccount status is received.

As a result, three options can be used to send messages and get the Chat identifier:

  1. (recommended) Use a previously saved value, for example from your database, as the Chat identifier. Use this value to send a message.
  2. (recommended) Get the Chat identifier by the CheckAccount method and then send a message.
  3. Send a message by the contact's username