How to send Emoji with Telegram Bot API?

How to send Emoji with Telegram Bot API?

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

Why Text Emojis Fail and Unicode Characters Succeed

When building a Telegram bot, you might assume that any string of characters sent to the user will render exactly as typed. However, relying on Telegram's internal text emoji codes like :nine: directly in the message payload often results in the bot displaying plain text instead of the expected graphic icon. This behavior stems from how the Telegram Bot API handles input data versus how clients interpret it.

The code snippet provided in your inquiry demonstrates a common misunderstanding of the API's expectations. In your example, you are constructing a POST request where the text field contains the string My number - :nine:. When this payload reaches the Telegram servers and then the client application (be it the mobile app or web version), the client does not automatically recognize :nine: as an instruction to fetch an image asset. Instead, most clients treat unrecognized text sequences as literal characters unless they are part of a specific markup language that supports rich text elements.

To successfully render an emoji icon, you must bypass the text shortcode mechanism entirely and send the actual Unicode character directly within the message string. The Telegram Bot API is designed to handle UTF-8 encoded strings for the text parameter. As long as your HTTP client (in this case, cURL) sends the correct byte sequence for the desired emoji, the API will accept it, and the receiving client will render it immediately.

Consider the difference between sending a shortcode and sending a character. When you use :nine:, you are relying on a legacy or client-specific rendering engine that is not guaranteed to be active in all contexts, particularly within raw API calls. By replacing the text parameter value with My number - 9️⃣ (using the actual Unicode character for the keycap nine), you ensure that the message payload contains the exact data required for universal rendering.

In PHP, sending this character is straightforward because modern encodings handle UTF-8 natively. You do not need to escape the character or encode it into a base64 string unless there are specific constraints on your backend environment. The cURL request should look something like this:

function tel_send($key, $t, $c) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://api.telegram.org/bot" . $key . "/sendMessage");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, true);
    // Ensure the text contains the actual Unicode character, not a shortcode
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
        'chat_id' => $c,
        'text' => "My number - 9️⃣" 
    ]));
    $ss = curl_exec($ch);
    curl_close($ch);
    return $ss;
}

// Usage
tel_send($key, "My number - 9️⃣", $val['message']['chat']['id']);

There is a critical trade-off to consider when choosing this approach: character encoding consistency. While the Telegram API supports UTF-8, some older PHP configurations or custom string manipulation functions might strip or mangle non-ASCII characters if the source file or server environment is not strictly set to UTF-8. If you encounter issues where emojis appear as question marks or garbled text, verify that your .php files are saved with a UTF-8 BOM (or without it, depending on specific editor settings) and that the server's default_charset is configured correctly.

Additionally, be aware that not all platforms render every Unicode emoji identically. The Telegram client has its own mapping of these characters to specific assets. While sending the standard Unicode character works for the vast majority of cases, relying on platform-specific shortcodes (like :nine:) is a fragile strategy because it requires both the sender and receiver to agree on a rendering engine that supports those specific tags. By shifting to direct Unicode characters, you align your bot's behavior with the modern standard used by almost all messaging applications today.

For developers using frameworks like Laravel, this principle remains consistent regardless of the underlying language. Whether you are using a raw HTTP client or integrating with a library like guzzlehttp/guzzle, the payload must contain the UTF-8 bytes of the emoji itself. If you are managing complex message formatting, always ensure that any string concatenation involving user input is sanitized to prevent injection attacks, as appending emojis to dynamic strings does not negate the need for input validation.

If you require more robust handling of rich text or want to explore how different clients parse Telegram messages, resources like https://laravelcompany.com can provide insights into modern PHP development patterns that ensure your application remains secure and compatible with evolving API standards.

Our network