Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Slack Share Update Trigger #21

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions triggers/slack-share-update/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Slack Share Update

Notify a Slack #channel when you finish a call or want to pair.

## Setup

1. Go to your Slack app's incoming webhooks page: https://YOUR_WORKSPACE.slack.com/apps/A0F7XDUAZ-incoming-webhooks.
2. Click "Add to Slack".
3. Choose the channel where notifications should be posted, and click "Add Incoming Webhooks Integration".
4. Copy the webhook URL provided. This URL is used to post messages from external sources into Slack.

In the [room-joined script](./room-joined), [room-left script](./room-left) and [call-ended script](./call-ended) replace the `SLACK_WEBHOOK_URL` variable with the new webhook URL you generated above.

Binary file added triggers/slack-share-update/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions triggers/slack-share-update/call-ended
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

# Replace with your generated URL from README instructions.
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/xxxxxxxxx/yyyyyyyyyy/zzzzzzzzzz

# Construct the initial part of the message
INITIAL_MESSAGE="$TUPLE_TRIGGER_FULL_NAME just finished pairing, here's what they said"

# AppleScript for input dialog to get additional details
DETAILS=$(osascript -e 'Tell application "System Events" to display dialog "Enter details about the call to send to Slack (you will have a chance to preview before sending):" default answer ""' -e 'text returned of result' 2>/dev/null)

# Check if user pressed "Cancel"
if [ $? -ne 0 ]; then
echo "User canceled the input dialog. Exiting script."
exit 0
fi

# Combine the initial part with the user-provided details
FULL_MESSAGE="$INITIAL_MESSAGE - '$DETAILS'"

# Preview the message
RESPONSE=$(osascript -e 'Tell application "System Events" to display dialog "Send this message to Slack?\n\n'"$FULL_MESSAGE"'" buttons {"Cancel", "Send"} default button "Send"' -e 'button returned of result' 2>/dev/null)

# Check if user confirmed to send the message
if [ "$RESPONSE" = "Send" ]; then
# Properly escape the message for JSON and send it to Slack
ESCAPED_MESSAGE=$(echo "$FULL_MESSAGE" | sed 's/"/\\"/g; s/\\/\\\\/g; s/\//\\\//g; s/`/\\`/g')
JSON_PAYLOAD="{\"text\": \"$ESCAPED_MESSAGE\"}"
curl -X POST -H 'Content-type: application/json' --data "$JSON_PAYLOAD" "$SLACK_WEBHOOK_URL"
else
echo "User canceled the preview dialog. Exiting script."
fi
6 changes: 6 additions & 0 deletions triggers/slack-share-update/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Slack Share Update",
"description": "Notify a Slack channel what you worked on, or what you want to pair on.",
"platforms": ["macos"],
"language": "bash"
}
34 changes: 34 additions & 0 deletions triggers/slack-share-update/room-joined
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# Replace with your generated URL from README instructions.
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/xxxxxxxxx/yyyyyyyyyy/zzzzzzzzzz

if [ -n "$TUPLE_TRIGGER_IS_SELF" ]; then
# Construct the initial part of the message
INITIAL_MESSAGE="$TUPLE_TRIGGER_FULL_NAME has joined the $TUPLE_TRIGGER_ROOM_NAME room, here's what they want to chat about"

# AppleScript for input dialog to get additional details
DETAILS=$(osascript -e 'Tell application "System Events" to display dialog "Enter what you want to chat about to send to Slack (you will have a chance to preview before sending):" default answer ""' -e 'text returned of result' 2>/dev/null)

# Check if user pressed "Cancel"
if [ $? -ne 0 ]; then
echo "User canceled the input dialog. Exiting script."
exit 0
fi

# Combine the initial part with the user-provided details
FULL_MESSAGE="$INITIAL_MESSAGE - '$DETAILS'"

# Preview the message
RESPONSE=$(osascript -e 'Tell application "System Events" to display dialog "Send this message to Slack?\n\n'"$FULL_MESSAGE"'" buttons {"Cancel", "Send"} default button "Send"' -e 'button returned of result' 2>/dev/null)

# Check if user confirmed to send the message
if [ "$RESPONSE" = "Send" ]; then
# Properly escape the message for JSON and send it to Slack
ESCAPED_MESSAGE=$(echo "$FULL_MESSAGE" | sed 's/"/\\"/g; s/\\/\\\\/g; s/\//\\\//g; s/`/\\`/g')
JSON_PAYLOAD="{\"text\": \"$ESCAPED_MESSAGE\"}"
curl -X POST -H 'Content-type: application/json' --data "$JSON_PAYLOAD" "$SLACK_WEBHOOK_URL"
else
echo "User canceled the preview dialog. Exiting script."
fi
fi
34 changes: 34 additions & 0 deletions triggers/slack-share-update/room-left
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# Replace with your generated URL from README instructions.
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/xxxxxxxxx/yyyyyyyyyy/zzzzzzzzzz

if [ -n "$TUPLE_TRIGGER_IS_SELF" ]; then
# Construct the initial part of the message
INITIAL_MESSAGE="$TUPLE_TRIGGER_FULL_NAME just finished pairing in the $TUPLE_TRIGGER_ROOM_NAME room, here's what they said"

# AppleScript for input dialog to get additional details
DETAILS=$(osascript -e 'Tell application "System Events" to display dialog "Enter details about the call to send to Slack (you will have a chance to preview before sending):" default answer ""' -e 'text returned of result' 2>/dev/null)

# Check if user pressed "Cancel"
if [ $? -ne 0 ]; then
echo "User canceled the input dialog. Exiting script."
exit 0
fi

# Combine the initial part with the user-provided details
FULL_MESSAGE="$INITIAL_MESSAGE - '$DETAILS'"

# Preview the message
RESPONSE=$(osascript -e 'Tell application "System Events" to display dialog "Send this message to Slack?\n\n'"$FULL_MESSAGE"'" buttons {"Cancel", "Send"} default button "Send"' -e 'button returned of result' 2>/dev/null)

# Check if user confirmed to send the message
if [ "$RESPONSE" = "Send" ]; then
# Properly escape the message for JSON and send it to Slack
ESCAPED_MESSAGE=$(echo "$FULL_MESSAGE" | sed 's/"/\\"/g; s/\\/\\\\/g; s/\//\\\//g; s/`/\\`/g')
JSON_PAYLOAD="{\"text\": \"$ESCAPED_MESSAGE\"}"
curl -X POST -H 'Content-type: application/json' --data "$JSON_PAYLOAD" "$SLACK_WEBHOOK_URL"
else
echo "User canceled the preview dialog. Exiting script."
fi
fi