Created
November 11, 2018 17:26
-
-
Save gregmercer/5e6553a0e7d7fb590127ea0e921c1ead to your computer and use it in GitHub Desktop.
Slack node js code to take a user to a private channel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sendGoPrivateMessage(channel, user_id, firstName) { | |
let teamId = 'T########'; | |
let post = | |
{ | |
channel: channel, | |
user: user_id, | |
text: 'Hi ' + firstName + ', I can help you book your room. Let\'s work on your new reservation in private.' , | |
attachments: | |
[ | |
{ | |
text: 'Use this link if your are ' | |
+ '<https://' + appWorkspace + '/messages/@' + botId + '| using your Browser.>', | |
color: '#3AA3E3', | |
attachment_type: 'default' | |
}, | |
{ | |
text: 'Or use the following link if using the Slack App ', | |
color: '#3AA3E3', | |
attachment_type: 'default' | |
}, | |
{ | |
text: 'slack://channel?team=' + teamId + '&id=' + botChannel, | |
color: '#3AA3E3', | |
attachment_type: 'default' | |
} | |
], | |
response_type: 'ephemeral', | |
replace_original: true, | |
}; | |
slackWeb.chat.postMessage(post) | |
.then((res) => { | |
// 'res' contains information about the posted message | |
}) | |
.catch(console.error); | |
} // end of sendGoPrivateMessage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment