Slack Templates (Raw & Blocks API JSON) #1336
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Related issue (if applicable): #641
This PR adds the following functionality to the Slack plugin
(Similar to MSTeams implementation)
template
key to all Slack URLs accepts a file (or any attachment) which is used to generate the sent messageTokens prepended with
:
are dynamically added to the template (e.g:...&template=file.txt&:token=value
)Full Support of the Block Kit API
The templates can utilize the full power of the Blocks Kit API. If the AppRise URL contains
blocks=yes
, then the template file is parsed as JSON, and it is passed as-is. An example follows:template-blocks.json
NOTE: As you can see the
title
is not rendered, as it was not used in the template. With great power comes great responsibility.NOTE:
footer
and params that traditionally modify the message are ignored whentemplate
is used withblocks
.blocks
param, then the template is free text, only sent asbody
of the notification. Thetitle
is processed as usually.Checklist
flake8
)Testing
This PR's feature is testable by everyone!
We can use a Github Gist containing a template!
The Gist below contains the Blocks template used above:
https://gist.github.com/operatorequals/16864f51c215a0a9628f934b0740095a
We can use it by filling its Raw URL to the AppRise template, getting an AppRise URL as below:
NOTE: fill the
x
to your Slack Incoming Webhook valuesAnyone can help test this source code as follows: