-
Notifications
You must be signed in to change notification settings - Fork 786
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 Interactive Buttons for Slack message to approve and disapprove message from Slack #4393
base: master
Are you sure you want to change the base?
Add Interactive Buttons for Slack message to approve and disapprove message from Slack #4393
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #4393 +/- ##
==========================================
- Coverage 72.93% 69.30% -3.63%
==========================================
Files 83 20 -63
Lines 5368 3574 -1794
==========================================
- Hits 3915 2477 -1438
+ Misses 1453 1097 -356 see 64 files with indirect coverage changes see 64 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Instruction on how to add Interactive Endpoint to Slack: Then you can paste in your endpoint to Request URL. You may have to enable it first and add the bot to the channel. Read more here: https://api.slack.com/messaging/interactivity |
Instruction for the Slack Bot authentication Our bot will use the personal token to verify the source of the request. You'll have to go to your app -> Basic Information -> App Credentials -> Then Copy your Verification Token, created an env variable called |
"username": "EvalAI", | ||
} | ||
else: | ||
data = message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add condition to support 2 types of Slack message:
- Normal text message
- Message with interactive buttons (like the approve, disapprove)
@@ -260,6 +260,39 @@ def is_active(self): | |||
return False | |||
|
|||
|
|||
def slack_challenge_approval_callback(challenge_id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A function similar to create_eks_cluster_or_ec2_for_challenge
but used for Slack (cause we don't have instance
and created
if we call this function in our backend)
r"^challenge/slack_actions/$", | ||
views.slack_actions, | ||
name="challenge_slack_actions", | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An open endpoint for slack to send any action to (any click or any interaction will be sent here)
models.slack_challenge_approval_callback(challenge_id) | ||
|
||
return JsonResponse( | ||
{"text": f"Challenge {challenge_id} has been disapproved"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle the request from Slack, include our custom autherization method
"name": "approval", | ||
"text": "No", | ||
"type": "button", | ||
"value": f"disapprove_{challenge_pk}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add buttons to the Slack Message
This pull request adds interactive buttons to the Slack message for approving and disapproving a challenge. When the buttons are clicked, the corresponding action is performed and a response message is sent back to the backend.
Demo Vid:
2024-07-04.06-54-40.mp4