Forked from chusiang/teams-chat-post-for-workflows.sh
Created
August 7, 2024 10:15
-
-
Save JamesClonk/ad0da5c798bff3ade1ba6fb61bc7c97a to your computer and use it in GitHub Desktop.
Revisions
-
chusiang revised this gist
Jul 22, 2024 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ # ============================================================================= # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post-for-workflows.sh # Modified: 2024-07-22 11:44 (UTC+08:00) # Description: Post a message to Microsoft Teams via "Post to a chat when a webhook request is received" workflows. # Reference: # @@ -56,8 +56,8 @@ if [[ "${TEXT}" == "" ]]; then exit 1 fi # Escape char: `'`, `"`, `\` . MESSAGE=$(echo ${TEXT} | sed "s/'/\'/g" | sed 's/"/\"/g; s/\\/\\\\/g') # Adaptive Cards of TextBlock - https://adaptivecards.io/explorer/TextBlock.html JSON="{ -
chusiang revised this gist
Jul 17, 2024 . 1 changed file with 12 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,42 +21,43 @@ fi # Webhook or Token. WEBHOOK_URL=$1 if [[ "${WEBHOOK_URL}" == "" ]]; then echo "No webhook_url specified." exit 1 fi shift # Title . TITLE=$1 if [[ "${TITLE}" == "" ]]; then echo "No title specified." exit 1 fi shift # Color. COLOR=$1 if [[ "${COLOR}" == "" ]]; then echo "No status specified." exit 1 fi shift # Text. TEXT=$* if [[ "${TEXT}" == "" ]]; then echo "No text specified." exit 1 fi # Convert formating. MESSAGE=$(echo ${TEXT} | sed 's/"/\"/g' | sed "s/'/\'/g") JSON="{ \"title\": \"${TITLE}\", \"themeColor\": \"${COLOR}\", \"text\": \"${MESSAGE}\" }" # Post to Microsoft Teams. curl -H "Content-Type: application/json" -d "${JSON}" "${WEBHOOK_URL}" -
chusiang revised this gist
Jul 17, 2024 . 1 changed file with 18 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,13 +2,14 @@ # ============================================================================= # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post-for-workflows.sh # Modified: 2024-07-17 19:12 (UTC+08:00) # Description: Post a message to Microsoft Teams via "Post to a chat when a webhook request is received" workflows. # Reference: # # - https://gist.github.com/chusiang/895f6406fbf9285c58ad0a3ace13d025 # - https://devblogs.microsoft.com/microsoft365dev/retirement-of-office-365-connectors-within-microsoft-teams/ # - https://adaptivecards.io/explorer/ # - https://adaptivecards.io/designer/ # # ============================================================================= @@ -58,6 +59,7 @@ fi # Convert formating. MESSAGE=$(echo ${TEXT} | sed 's/"/\"/g' | sed "s/'/\'/g") # Adaptive Cards of TextBlock - https://adaptivecards.io/explorer/TextBlock.html JSON="{ \"type\": \"message\", \"attachments\": [ @@ -69,8 +71,21 @@ JSON="{ \"type\": \"AdaptiveCard\", \"version\": \"1.2\", \"body\": [ { \"type\": \"TextBlock\", \"text\": \"${TITLE}\", \"color\": \"${COLOR}\", \"weight\": \"bolder\", \"size\": \"large\", \"wrap\": true }, { \"type\": \"TextBlock\", \"text\": \"${MESSAGE}\", \"color\": \"${COLOR}\", \"size\": \"small\", \"wrap\": true } ] } } -
chusiang revised this gist
Jul 12, 2024 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,12 +2,13 @@ # ============================================================================= # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post-for-workflows.sh # Modified: 2024-07-12 19:29 (UTC+08:00) # Description: Post a message to Microsoft Teams via "Post to a chat when a webhook request is received" workflows. # Reference: # # - https://gist.github.com/chusiang/895f6406fbf9285c58ad0a3ace13d025 # - https://devblogs.microsoft.com/microsoft365dev/retirement-of-office-365-connectors-within-microsoft-teams/ # - https://adaptivecards.io/explorer/ # # ============================================================================= -
chusiang revised this gist
Jul 12, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -68,8 +68,8 @@ JSON="{ \"type\": \"AdaptiveCard\", \"version\": \"1.2\", \"body\": [ { \"type\": \"TextBlock\", \"text\": \"${TITLE}\", \"color\": \"${COLOR}\", \"wrap\": true }, { \"type\": \"TextBlock\", \"text\": \"${MESSAGE}\", \"color\": \"${COLOR}\", \"wrap\": true } ] } } -
chusiang revised this gist
Jul 12, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post-for-workflows.sh # Modified: 2024-07-12 18:46 (UTC+08:00) # Description: Post a message to Microsoft Teams via "Post to a chat when a webhook request is received" workflows. # Reference: # # - https://gist.github.com/chusiang/895f6406fbf9285c58ad0a3ace13d025 -
chusiang revised this gist
Jul 12, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -68,8 +68,8 @@ JSON="{ \"type\": \"AdaptiveCard\", \"version\": \"1.2\", \"body\": [ { \"type\": \"TextBlock\", \"text\": \"${TITLE}\", \"color\": \"${COLOR}\", \"warp\": true }, { \"type\": \"TextBlock\", \"text\": \"${MESSAGE}\", \"color\": \"${COLOR}\", \"warp\": true } ] } } -
chusiang revised this gist
Jul 12, 2024 . 1 changed file with 84 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,84 @@ #!/bin/bash # ============================================================================= # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post-for-workflows.sh # Modified: 2024-07-12 18:46 (UTC+08:00) # Description: Post a message to Microsoft Teams via Power Automate workflows mode. # Reference: # # - https://gist.github.com/chusiang/895f6406fbf9285c58ad0a3ace13d025 # - https://devblogs.microsoft.com/microsoft365dev/retirement-of-office-365-connectors-within-microsoft-teams/ # # ============================================================================= # Help. if [[ "$1" == "-h" || "$1" == "--help" ]]; then echo 'Usage: teams-chat-post.sh "<webhook_url>" "<title>" "<color>" "<message>"' exit 0 fi # Webhook or Token. WEBHOOK_URL=$1 if [[ "${WEBHOOK_URL}" == "" ]]; then echo "No webhook_url specified." exit 1 fi shift # Title . TITLE=$1 if [[ "${TITLE}" == "" ]]; then echo "No title specified." exit 1 fi shift # Color. COLOR=$1 if [[ "${COLOR}" == "" ]]; then echo "No status specified." exit 1 fi shift # Text. TEXT=$* if [[ "${TEXT}" == "" ]]; then echo "No text specified." exit 1 fi ATTACHMENTS=$* if [[ "${TEXT}" == "" ]]; then echo "No text specified." exit 1 fi # Convert formating. MESSAGE=$(echo ${TEXT} | sed 's/"/\"/g' | sed "s/'/\'/g") JSON="{ \"type\": \"message\", \"attachments\": [ { \"contentType\": \"application/vnd.microsoft.card.adaptive\", \"contentUrl\": null, \"content\": { \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\", \"type\": \"AdaptiveCard\", \"version\": \"1.2\", \"body\": [ { \"type\": \"TextBlock\", \"text\": \"${TITLE}\", \"color\": \"Light\", \"warp\": true }, { \"type\": \"TextBlock\", \"text\": \"${MESSAGE}\", \"warp\": true } ] } } ] }" # Post to Microsoft Teams via curl. curl \ --header "Content-Type: application/json" \ --request POST \ --data "${JSON}" \ "${WEBHOOK_URL}" -
chusiang revised this gist
Jul 12, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ # ============================================================================= # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post.sh # Modified: 2024-07-12 18:49 (UTC+08:00) # Description: Post a message to Microsoft Teams via connectors, not support # Power Automate workflows. # Reference: -
chusiang revised this gist
Jul 12, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,6 +9,7 @@ # # - https://gist.github.com/chusiang/895f6406fbf9285c58ad0a3ace13d025 # - https://devblogs.microsoft.com/microsoft365dev/retirement-of-office-365-connectors-within-microsoft-teams/ # - Fixed for workflows edition: https://gist.github.com/chusiang/895f6406fbf9285c58ad0a3ace13d025?permalink_comment_id=5119162#gistcomment-5119162 # # ============================================================================= -
chusiang revised this gist
Jul 9, 2024 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,11 +2,13 @@ # ============================================================================= # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post.sh # Modified: 2024-07-09 15:15 # Description: Post a message to Microsoft Teams via connectors, not support # Power Automate workflows. # Reference: # # - https://gist.github.com/chusiang/895f6406fbf9285c58ad0a3ace13d025 # - https://devblogs.microsoft.com/microsoft365dev/retirement-of-office-365-connectors-within-microsoft-teams/ # # ============================================================================= -
chusiang revised this gist
Jul 9, 2024 . No changes.There are no files selected for viewing
-
chusiang revised this gist
Oct 17, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ #!/bin/bash # ============================================================================= # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post.sh # Modified: 2021-10-18 00:09 # Description: Post a message to Microsoft Teams. # Reference: # -
chusiang revised this gist
Mar 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ # Help. if [[ "$1" == "-h" || "$1" == "--help" ]]; then echo 'Usage: teams-chat-post.sh "<webhook_url>" "<title>" "<color>" "<message>"' exit 0 fi # Webhook or Token. -
chusiang revised this gist
Mar 28, 2018 . 1 changed file with 14 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,18 +2,21 @@ # ============================================================================= # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post.sh # Modified: 2018-03-28 15:04 # Description: Post a message to Microsoft Teams. # Reference: # # - https://gist.github.com/chusiang/895f6406fbf9285c58ad0a3ace13d025 # # ============================================================================= # Help. if [[ "$1" == "-h" || "$1" == "--help" ]]; then echo 'Usage: teams-chat-post.sh "<webhook_url>" "<title>" "<color>" "<message>"' exit 1 fi # Webhook or Token. WEBHOOK_URL=$1 if [[ "${WEBHOOK_URL}" == "" ]] then @@ -22,7 +25,7 @@ then fi shift # Title . TITLE=$1 if [[ "${TITLE}" == "" ]] then @@ -31,7 +34,7 @@ then fi shift # Color. COLOR=$1 if [[ "${COLOR}" == "" ]] then @@ -40,17 +43,17 @@ then fi shift # Text. TEXT=$* if [[ "${TEXT}" == "" ]] then echo "No text specified." exit 1 fi # Convert formating. MESSAGE=$( echo ${TEXT} | sed 's/"/\"/g' | sed "s/'/\'/g" ) JSON="{\"title\": \"${TITLE}\", \"themeColor\": \"${COLOR}\", \"text\": \"${MESSAGE}\" }" # Post to Microsoft Teams. curl -H "Content-Type: application/json" -d "${JSON}" "${WEBHOOK_URL}" -
chusiang revised this gist
Mar 28, 2018 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ #!/bin/sh # ============================================================================= # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post.sh # Modified: 2018-03-28 15:38 @@ -11,7 +11,7 @@ # # - https://gist.github.com/dopiaza/6449505#gistcomment-1627214 # # ============================================================================= # webhook & token. WEBHOOK_URL=$1 -
chusiang revised this gist
Mar 28, 2018 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ #!/bin/sh # ============================================================ # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post.sh # Modified: 2018-03-28 15:38 # Description: Post a message to Microsoft Teams. # # Usage: teams-chat-post.sh "<webhook_url>" "<title>" "<color>" "<message>" @@ -15,7 +15,7 @@ # webhook & token. WEBHOOK_URL=$1 if [[ "${WEBHOOK_URL}" == "" ]] then echo "No webhook_url specified." exit 1 @@ -24,7 +24,7 @@ shift # title . TITLE=$1 if [[ "${TITLE}" == "" ]] then echo "No title specified." exit 1 @@ -33,7 +33,7 @@ shift # color. COLOR=$1 if [[ "${COLOR}" == "" ]] then echo "No status specified." exit 1 @@ -42,15 +42,15 @@ shift # text. TEXT=$* if [[ "${TEXT}" == "" ]] then echo "No text specified." exit 1 fi # convert formating. MESSAGE=$( echo ${TEXT} | sed 's/"/\"/g' | sed "s/'/\'/g" ) JSON="{\"title\": \"${TITLE}\", \"themeColor\": \"${COLOR}\", \"text\": \"${MESSAGE}\" }" # post to slack. curl -H "Content-Type: application/json" -d "${JSON}" "${WEBHOOK_URL}" -
chusiang created this gist
Mar 28, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ #!/bin/bash # ============================================================ # Author: Chu-Siang Lai / chusiang (at) drx.tw # Filename: teams-chat-post.sh # Modified: 2018-03-28 15:04 # Description: Post a message to Microsoft Teams. # # Usage: teams-chat-post.sh "<webhook_url>" "<title>" "<color>" "<message>" # # Reference: # # - https://gist.github.com/dopiaza/6449505#gistcomment-1627214 # # ============================================================ # webhook & token. WEBHOOK_URL=$1 if [[ $WEBHOOK_URL == "" ]] then echo "No webhook_url specified." exit 1 fi shift # title . TITLE=$1 if [[ $TITLE == "" ]] then echo "No title specified." exit 1 fi shift # color. COLOR=$1 if [[ $COLOR == "" ]] then echo "No status specified." exit 1 fi shift # text. TEXT=$* if [[ $TEXT == "" ]] then echo "No text specified." exit 1 fi # convert formating. MESSAGE=$( echo $TEXT | sed 's/"/\"/g' | sed "s/'/\'/g" ) JSON="{\"title\": \"$TITLE\", \"themeColor\": \"$COLOR\", \"text\": \"$MESSAGE\" }" # post to slack. curl -H "Content-Type: application/json" -d "$JSON" "$WEBHOOK_URL"