Skip to content

Document generic webhooks #8609

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

Merged
merged 26 commits into from
Nov 8, 2021
Merged

Document generic webhooks #8609

merged 26 commits into from
Nov 8, 2021

Conversation

astrojuanlu
Copy link
Contributor

@astrojuanlu astrojuanlu commented Oct 21, 2021

Continuation of #8522.

I considered renaming the file from build-notifications to build-notifications-webhooks, but was unsure if it was worth it. I ended up renaming the title though.

@astrojuanlu astrojuanlu requested review from stsewd and a team October 21, 2021 18:59
@astrojuanlu astrojuanlu requested a review from a team as a code owner October 21, 2021 18:59
@astrojuanlu
Copy link
Contributor Author

Copy link
Member

@stsewd stsewd left a comment

Choose a reason for hiding this comment

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

I was thinking we could provide some examples of payloads ready to use for slack & discord, so users just need to copy/paste things.

https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
https://app.slack.com/block-kit-builder/T02J81RRP

@stsewd
Copy link
Member

stsewd commented Oct 21, 2021

oh, we should also document about the signature check

headers['X-Hub-Signature'] = webhook.sign_payload(payload)
, maybe have a small python code as example on how to check the signature, which is the same process from
def sign_payload(self, payload):
"""Get the signature of `payload` using HMAC-SHA1 with the webhook secret."""
digest = hmac.new(
key=self.secret.encode(),
msg=payload.encode(),
digestmod=hashlib.sha1,
)
return digest.hexdigest()

for example

@humitos
Copy link
Member

humitos commented Oct 25, 2021

I was thinking we could provide some examples of payloads ready to use for slack & discord, so users just need to copy/paste things.

I also think this is important 💯

@astrojuanlu
Copy link
Contributor Author

I added Slack and Discord examples as suggested 👍🏽

@astrojuanlu
Copy link
Contributor Author

Added another section on payload validation, please verify. I don't know if there are any coding standards for this kind of verifications.

@astrojuanlu
Copy link
Contributor Author

There's a bit of git mess here (merge of merge of merge...) so @stsewd I will let you decide whether to merge this pull request to webhooks directly or if you want to rebase and merge.

@stsewd
Copy link
Member

stsewd commented Oct 25, 2021

There's a bit of git mess here (merge of merge of merge...)

Since this isn't touching anything from the code on the other PR we could also just set the base branch as master, and then merge the two PRs the same day.

astrojuanlu and others added 3 commits October 25, 2021 19:07
@astrojuanlu astrojuanlu force-pushed the webhooks-documentation branch from 6b66724 to 8f55e27 Compare October 25, 2021 17:11
Copy link
Member

@stsewd stsewd left a comment

Choose a reason for hiding this comment

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

I'll see if I can get some screenshots of the final result of the slack/discord messages. We could merge this when the other PR is merged and update any variables if needed.

@astrojuanlu astrojuanlu force-pushed the webhooks-documentation branch from 683789b to fe45d31 Compare October 25, 2021 17:57
@stsewd
Copy link
Member

stsewd commented Oct 25, 2021

screenshots using the payload from the examples

Screenshot 2021-10-25 at 13-37-15 Slack Block Kit Builder

image

Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

This is a good refactor, but could still use a bit more context. I really feel that having to copy/paste a jumble of JSON to support very common webhooks is a poor product experience, so I'd really like us to see if we can support a nicer workflow there by default with just a button or dropdown Webhook format: Slack, Discord, Custom or something.


The project name, slug and its details for the build will be sent as POST request to your webhook URL:
More information on `the Slack Incoming Webhooks documentation <https://api.slack.com/messaging/webhooks>`_.
Copy link
Member

Choose a reason for hiding this comment

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

This feels like bad UX. I would strongly suggest that we implement a standard Slack webhook option, instead of forcing users to copy & paste large bits of JSON into our dashboard. /cc @stsewd

Copy link
Member

Choose a reason for hiding this comment

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

would this be an option to pre-fill the content, or just an option where users don't have control over?

Copy link
Member

Choose a reason for hiding this comment

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

We have this for automation rules for example

Screenshot from 2021-10-26 13-27-16

But I'd prefer the option to pre-fill the content

Copy link
Member

Choose a reason for hiding this comment

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

and user would still need to setup webhook from their side on slack/discord.

Copy link
Member

Choose a reason for hiding this comment

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

@stsewd I think something that we control should be the default. Many users don't actually want to think about this, and having something that we control and can improve over time without users having to touch it feels like better UX?

Copy link
Member

Choose a reason for hiding this comment

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

In the same fashion, imagine that Slack changed their webhook format or something. It would be a huge pain if we had to email every user to ask them to update the blob of JSON in the config. We should definitely support "Slack" as a first-class option that we control the format of.

Copy link
Member

Choose a reason for hiding this comment

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

I guess if that happens slack will provide users a different url or option, then we are forced to support both formats using an option or something.

My other worry here is if we change something, it will affect everyone, users may not like something from the new change and will request for options, and we end up adding a lot of options in the UI or the users will end up creating their own custom payload at the end.

Copy link
Member

Choose a reason for hiding this comment

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

@stsewd Valid concerns, but I think there are a large number of users who just want "Slack notifications" that work well. Asking them to customize them is an actively negative experience. I think we want both the simple & custom, so users can choose what works better for them.

@astrojuanlu
Copy link
Contributor Author

Hi folks, I lost track of the discussion at #8522 and feature proposals that were suggested, too many messages. Is there consensus on the usage already? May I continue working on this? @stsewd @ericholscher

@stsewd
Copy link
Member

stsewd commented Nov 2, 2021

@astrojuanlu this is it #8522 (comment)

@astrojuanlu
Copy link
Contributor Author

Ready for another pass!

Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

Looks good to me, with a couple nits 👍


The project name, slug and its details for the build will be sent as POST request to your webhook URL:
More information on `the Slack Incoming Webhooks documentation <https://api.slack.com/messaging/webhooks>`_.
Copy link
Member

Choose a reason for hiding this comment

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

@stsewd Valid concerns, but I think there are a large number of users who just want "Slack notifications" that work well. Asking them to customize them is an actively negative experience. I think we want both the simple & custom, so users can choose what works better for them.

Co-authored-by: Eric Holscher <[email protected]>
]
}

More information on `the Discord webhooks documentation <https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks>`_.
Copy link
Member

Choose a reason for hiding this comment

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

I think we should maybe start each section with the links to the docs to create the webhhok on slack/discord and then give them the payload to use (Follow this steps on discord/slack, use the given URL when creating a webhook on rtd and add this payload).

@astrojuanlu
Copy link
Contributor Author

This has been approved already three times, and I keep having to catch up with the webhooks branch. To simplify things, I'm going to merge this already, and I think we can make changes in future PRs.

Co-authored-by: Santos Gallegos <[email protected]>
@astrojuanlu astrojuanlu merged commit d1a21f0 into webhooks Nov 8, 2021
@astrojuanlu astrojuanlu deleted the webhooks-documentation branch November 8, 2021 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants