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

feat: add discussion saviour bot as as lambda function #1194

Merged
merged 21 commits into from
Mar 16, 2023

Conversation

KhudaDad414
Copy link
Member

@KhudaDad414 KhudaDad414 commented Dec 28, 2022

Description

  • This lambda function will work as the backend for the bot that we will use in slack to move discussions to GitHub.
  • Before merging, we should make sure that the following environment variables are in place:
SLACK_TOKEN
GITHUB_TOKEN
DISCUSSION_TARGET_REPO_OWNER
DISCUSSION_TARGET_REPO_NAME

after this PR is merged, we can update its link in slack and everything should be in place.

How it works

this is how a thread can be moved to GitHub:

  1. Select Save to GitHub in the overflow menu of the message:

Screenshot 2022-12-28 at 17 57 57

  1. Fill the title and select the discussion category that it belongs to:

Screenshot 2022-12-28 at 17 58 21

  1. Click on save.

  2. A message will be posted in that thread confirming where the message is preserved.

Screenshot 2023-02-23 at 18 25 21

How it looks

Screenshot 2023-02-23 at 18 28 42

@netlify
Copy link

netlify bot commented Dec 28, 2022

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit c98a5f1
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/64130ec359d7df0009ebd767
😎 Deploy Preview https://deploy-preview-1194--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Dec 28, 2022

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 61
🟠 Accessibility 88
🟢 Best practices 100
🟢 SEO 100
🔴 PWA 30

Lighthouse ran on https://deploy-preview-1194--asyncapi-website.netlify.app/

Copy link
Member

@magicmatatjahu magicmatatjahu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work! As I see you didn't install the @netlify/functions dependency, so how did you test it 😄?

netlify/functions/save-discussion/index.ts Show resolved Hide resolved
netlify/functions/save-discussion/index.ts Outdated Show resolved Hide resolved
netlify/functions/save-discussion/index.ts Outdated Show resolved Hide resolved
netlify/functions/save-discussion/index.ts Outdated Show resolved Hide resolved
netlify/functions/save-discussion/index.ts Outdated Show resolved Hide resolved
netlify/functions/save-discussion/GithubReposity.ts Outdated Show resolved Hide resolved
netlify/functions/save-discussion/GithubReposity.ts Outdated Show resolved Hide resolved
KhudaDad414 and others added 7 commits January 9, 2023 10:37
Co-authored-by: Maciej Urbańczyk <urbanczyk.maciej.95@gmail.com>
Co-authored-by: Maciej Urbańczyk <urbanczyk.maciej.95@gmail.com>
Co-authored-by: Maciej Urbańczyk <urbanczyk.maciej.95@gmail.com>
Co-authored-by: Maciej Urbańczyk <urbanczyk.maciej.95@gmail.com>
Co-authored-by: Maciej Urbańczyk <urbanczyk.maciej.95@gmail.com>
Copy link
Member Author

@KhudaDad414 KhudaDad414 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@magicmatatjahu thanks for the review. I was actually testing it in another repo 😆
👁️ 🙏

netlify/functions/save-discussion/index.ts Show resolved Hide resolved
@KhudaDad414
Copy link
Member Author

@derberg @magicmatatjahu @akshatnema pinging for visibility.

Copy link
Member

@akshatnema akshatnema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KhudaDad414 Can you please add comments for future reference so that everyone can understand the implementation and logic behind code.

Also, will the Save to Github feature be enabled to all users? If yes, the user has to integrate GitHub with Slack in order to save the Slack in a Discussion?

},
"devDependencies": {
"@netlify/functions": "^1.4.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we add @netlify/functions as a devDependency as we need netlify cli to integrate Netlify functions with frontend?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have only been using some types from @netlify/functions and it's cli for testing functions. that's why I think it should be in devDependencies.

@KhudaDad414
Copy link
Member Author

KhudaDad414 commented Feb 4, 2023

@akshatnema Hey mate. I have refactored the code and added comments for clarity. 👀 🙏

will the Save to Github feature be enabled to all users? If yes, the user has to integrate GitHub with Slack in order to save the Slack in a Discussion?

Yes, It will be enabled for all users. And no, users won't need a GitHub with Slack integration for this to work since we will use one of the bot's API keys to access Slack discussions and store them in GitHub.

@KhudaDad414 KhudaDad414 requested review from akshatnema and removed request for magicmatatjahu February 4, 2023 14:49
@akshatnema
Copy link
Member

Sorry for the delay @KhudaDad414, I was quite on medical leave and just recovered from it in weekend.

Yes, It will be enabled for all users. And no, users won't need a GitHub with Slack integration for this to work since we will use one of the bot's API keys to access Slack discussions and store them in GitHub.

So, if everyone has access, it may happen the someone from the community spam a lot of threads in the GitHub discussions. We in this case should have control over this. And also, our API Key has been used to generate Github discussions, the token may result in rate limit due to excessive use by community members. So, in my opinion, you should have some restrictions on the use of this feature. WDYT? @derberg

@KhudaDad414
Copy link
Member Author

KhudaDad414 commented Feb 14, 2023

@akshatnema Happy to hear that you have recovered. Welcome back, mate!

@KhudaDad414
Copy link
Member Author

So, if everyone has access, it may happen the someone from the community spam a lot of threads in the GitHub discussions. We in this case should have control over this.

I think the best we can do is improve the message to show the user who saved the discussion and then we can block the bad actors from the Slack community itself.
or as you said limit the users who can use it, maybe TSC members only? would like to know what others think.

the token may result in a rate limit due to excessive use by community members.

I don't think the usage area of this feature is that common. Yes, it can happen but the user has to save around 100 discussions to use 1000 points. which I don't think is that worrisome.

@akshatnema
Copy link
Member

or as you said limit the users who can use it, maybe TSC members only? would like to know what others think.

I will prefer for having this permission for TSC_Members only because for any thread in Slack, a TSC member can very well judge/decide whether this thread should be saved in discussion or not. Secondly, if a non-TSC member wants to save a thread of Slack, he can surely ask any of the TSC members or Community managers (like @derberg) to add the respective thread on GitHub. This is what I think about the functionality we should have.

@derberg
Copy link
Member

derberg commented Feb 22, 2023

tbh I do not worry people will spam us because of misuse. We were afraid the same will happen with feedback for on docs, and yeah, nothing bad happened.

I'm more concerned on the limit of free functions invocation, but again, YOLO 😆 , if we will hit the limit, we can think about custom backend on digital ocean 🤷🏼

In github discussion, at the top, in main message we need to indicate where it is coming from, and provide link to slack

btw Khuda you plan to write an article about it, right? RIGHT? 😄


btw nice code, if only not TS 🤣

@KhudaDad414
Copy link
Member Author

In github discussion, at the top, in main message we need to indicate where it is coming from, and provide link to slack

It was there in the first version, 🤦 adding it now.

btw Khuda you plan to write an article about it, right? RIGHT? 😄

right. 😄

btw nice code, if only not TS 🤣

Come on man, don't do whatever you did to Twitter to TS as well. 😆 some of us actually like it. 😄

@KhudaDad414
Copy link
Member Author

@derberg 👁️ 🙏

Copy link
Member

@akshatnema akshatnema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish I could test this on some of my test repos but looks like will not be able to. But yeah, I believe in @KhudaDad414 and hence approving ✔️

@KhudaDad414
Copy link
Member Author

@akshatnema thanks mate.

Copy link
Member

derberg commented Mar 15, 2023

@akshatnema yeah this dude already pushed some not tested changes to CI and I bet he learned to test things now before merging 😆

@KhudaDad414 from Poland with love 😆

btw netlify environment variable is set and ready

@KhudaDad414
Copy link
Member Author

@derberg Those are some big allegations you are making brother. (please don't send any links in this PR, we don't like that. 😆)

@KhudaDad414
Copy link
Member Author

/rtm

@asyncapi-bot asyncapi-bot merged commit 595fb72 into asyncapi:master Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants