PSSlack icon indicating copy to clipboard operation
PSSlack copied to clipboard

Add support for posting interactive messages

Open devblackops opened this issue 8 years ago • 1 comments

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

Interactive Buttons Interactive Menus

devblackops avatar Aug 23 '17 06:08 devblackops

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!

RamblingCookieMonster avatar Aug 28 '17 19:08 RamblingCookieMonster