In order to send yourself a message via Telegram you need to do 3 things. Create a bot, get your chat id, start a chat with that bot, and finally send a message via the command line.

Step 1: Set up your bot

All Telegram bots have global visibility. This is important when setting the name for your bot. I have several bot, so I name them myusername_botname. This makes it so my bots all have similar names.

In order to set up a bot, you need to start a chat with @botfather. Send the message /newbot and the BotFather will walk you though setting up your new bot. This is what a typical conversation will look like:

[2:21:03 PM] George:

[2:21:03 PM] BotFather:
Alright, a new bot. How are we going to call it? Please choose a name for your bot.

[2:21:08 PM] George:

[2:21:07 PM] BotFather:
Good. Now let's choose a username for your bot. It must end in `bot`. Like this, for example: TetrisBot or tetris_bot.

[2:21:26 PM] George:

[2:21:25 PM] BotFather:
Done! Congratulations on your new bot. You will find it at You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.

Use this token to access the HTTP API:

For a description of the Bot API, see this page:

Congratulations, you have created a bot! Make sure you save the access token (i.e. api key)! You will need it to create requests.

Step 2: Get your chat id

To get your chat id you will need to start a chat with @idbot, and send the message /getid. The chat id will be a number like 394882049.

Step 3: Start chat with your new bot

This is easy. Just start a new chat with @your_bot_name. This is necessary, though, or your bot will be unable to send messages to you.

Step 4: Send message via BASH

You need cURL installed. Use the following command to test your bot.

curl -s "$API_KEY/sendMessage?chat_id=$CHAT_ID&text=helloworld"

Make sure to replace the variables:
$API_KEY = the access token from Step 1
$CHAT_ID = the chat id from step 2

You should get a JSON response to let you know if it was successful.


If you get the error {"ok":false,"error_code":400,"description":"Bad Request: chat not found"}# that either means that your chat_id is incorrect, or that you haven’t started a conversation with the bot yet (see step 3)