Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Created August 11, 2021 06:25
Show Gist options
  • Save percybolmer/90b71ec7a6a22588c37ea985cadf7c08 to your computer and use it in GitHub Desktop.
Save percybolmer/90b71ec7a6a22588c37ea985cadf7c08 to your computer and use it in GitHub Desktop.
// handleIsArticleGood will trigger a Yes or No question to the initializer
func handleIsArticleGood(command slack.SlashCommand, client *slack.Client) (interface{}, error) {
// Create the attachment and assigned based on the message
attachment := slack.Attachment{}
// Create the checkbox element
checkbox := slack.NewCheckboxGroupsBlockElement("answer",
slack.NewOptionBlockObject("yes", &slack.TextBlockObject{Text: "Yes", Type: slack.MarkdownType}, &slack.TextBlockObject{Text: "Did you Enjoy it?", Type: slack.MarkdownType}),
slack.NewOptionBlockObject("no", &slack.TextBlockObject{Text: "No", Type: slack.MarkdownType}, &slack.TextBlockObject{Text: "Did you Dislike it?", Type: slack.MarkdownType}),
)
// Create the Accessory that will be included in the Block and add the checkbox to it
accessory := slack.NewAccessory(checkbox)
// Add Blocks to the attachment
attachment.Blocks = slack.Blocks{
BlockSet: []slack.Block{
// Create a new section block element and add some text and the accessory to it
slack.NewSectionBlock(
&slack.TextBlockObject{
Type: slack.MarkdownType,
Text: "Did you think this article was helpful?",
},
nil,
accessory,
),
},
}
attachment.Text = "Rate the tutorial"
attachment.Color = "#4af030"
return attachment, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment