Add support for posting interactive messages
I'm starting to brainstorm how I can add support for interactive messages in PoshBot. Creating a interactive message using PSSlack with a bit of extra properties on the attachment object is easy enough but it would be nice if PSSlack supported those constructs natively.
Example of posting interactive message
$tok = '<your-token>'
$attParams = @{
Text = 'Choose a game to play'
Fallback = 'You are unable to choose a game'
Color = '#3AA3E3'
}
$att = New-SlackMessageAttachment @attParams
$att.callback_id = 'wopr_game'
$att.attachment_type = 'default'
$att.actions = @(
@{
name = 'game'
text = 'Chess'
type = "button"
value = "chess"
}
@{
name = "game"
text = "Falken's Maze"
type = "button"
value = "maze"
}
@{
name = "game"
text = "Thermonuclear War"
style = "danger"
type = "button"
value = "war"
confirm = @{
title = "Are you sure?"
text = "Wouldn't you prefer a good game of chess?"
ok_text = "Yes"
dismiss_text = "No"
}
}
)
$text = 'Would you like to play a game?'
$m = New-SlackMessage -Channel 'testing' -Text $text -AsUser -Attachments $att
$m | Send-SlackMessage -Token $tok -Verbose
Maybe the following new parameters could be added to New-SlackMessageAttachment to support button and menus?
- callback_id
- attachment_type
- actions
New functions for creating the button/menu actions and just a single Actions parameters on New-SlackMessageAttachment could also make sense. Food for thought.
Reference
Awesome idea! Yeah, would definitely make sense to abstract it out - I like the first idea, a bit more flexible from what I can tell, or at least, less complexity and fewer assumption in parsing?
Sort of tied up with a fun neo4j module; if anyone wants to take this feel free! Otherwise will remove the help wanted tag if I can find time
Cheers!