Skip to content

Instantly share code, notes, and snippets.

@mitinarseny
Last active January 18, 2020 12:50
Show Gist options
  • Save mitinarseny/2e7f8b3063ad1999e5701fdf5f021ece to your computer and use it in GitHub Desktop.
Save mitinarseny/2e7f8b3063ad1999e5701fdf5f021ece to your computer and use it in GitHub Desktop.
Send Telegram messages with curl

Send Telegram messages with curl

Dependencies

  • curl: command-line tool for transferring data with URLs
  • jq: lightweight and flexible command-line JSON processor

Environment

Firstly, you need to export BOT_TOKEN and CHAT_ID:

export BAT_TOKEN="<your_bot_token>"
export CHAT_ID="<your_chat_id>"

Send

sendMessage

curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
  -H "Content-Type: application/json; charset=utf-8" \
  -d "{
    \"chat_id\": \"${CHAT_ID}\",
    \"text\": \"Simple Text\",
    \"parse_mode\": \"Markdown\",
    \"disable_web_page_preview\": true,
    \"disable_notification\": true,
  }"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment