Skip to content

Instantly share code, notes, and snippets.

@kilfu0701
Created October 28, 2022 09:17
Show Gist options
  • Save kilfu0701/6f5d73caf776a1f073bd297516d69e4e to your computer and use it in GitHub Desktop.
Save kilfu0701/6f5d73caf776a1f073bd297516d69e4e to your computer and use it in GitHub Desktop.
Send message to Google Chat with bash script.
#/bin/bash
set -e
# set your BOT's API KEY and TOKEN
API_KEY=******************************
API_TOKEN=****************************
## send notification to google chat with card format.
#
# sample:
# _send_card "<b>Roses</b> are <font color=\\\"#ff0000\\\">red</font>,<br><i>Violets</i> are <font color=\\\"#0000ff\\\">blue</font>"
#
_send_card() {
jd='{"cards":[{"sections":[{"widgets":[{"textParagraph":{"text":"'$1'"}}]}]}]}'
curl -X POST -H "Content-Type:application/json" -d "$jd" "https://chat.googleapis.com/v1/spaces/AAAAsBfQRug/messages?key=$API_KEY&token=$API_TOKEN"
}
_send_card "<b>Roses</b> are <font color=\\\"#ff0000\\\">red</font>,<br><i>Violets</i> are <font color=\\\"#0000ff\\\">blue</font>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment