Skip to content

Instantly share code, notes, and snippets.

@mbrevoort
Last active January 9, 2017 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbrevoort/888100d20ce3f98a101385c84793a8b1 to your computer and use it in GitHub Desktop.
Save mbrevoort/888100d20ce3f98a101385c84793a8b1 to your computer and use it in GitHub Desktop.
Slack Message Builder Example
const smb = require('slack-message-builder')
smb()
.text("Would you like to play a game?")
.attachment()
.text("Choose a game to play")
.fallback("You are unable to choose a game")
.callbackId("wopr_game")
.color("#3AA3E3")
.action()
.name("chess")
.text("Chess")
.type("button")
.value("chess")
.end()
.action()
.name("maze")
.text("Falken's Maze")
.type("button")
.value("maze")
.end()
.action()
.name("war")
.text("Thermonuclear War")
.style("danger")
.type("button")
.value("war")
.confirm()
.title("Are you sure?")
.text("Wouldn't you prefer a good game of chess?")
.okText("Yes")
.dismissText("No")
.end()
.end()
.end()
.json()
{
"text": "Would you like to play a game?",
"attachments": [
{
"text": "Choose a game to play",
"fallback": "You are unable to choose a game",
"callback_id": "wopr_game",
"color": "#3AA3E3",
"actions": [
{
"name": "chess",
"text": "Chess",
"type": "button",
"value": "chess"
},
{
"name": "maze",
"text": "Falken's Maze",
"type": "button",
"value": "maze"
},
{
"name": "war",
"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"
}
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment