This repository was archived by the owner on Jul 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
55 lines (51 loc) · 1.19 KB
/
Copy pathapp.js
File metadata and controls
55 lines (51 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const {
WebClient
} = require('@slack/web-api');
const ChannelId = process.env.CHANNEL_ID;
const SlackToken = process.env.SLACK_TOKEN;
const web = new WebClient(SlackToken);
const MessageBlock = [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hi Rod :wave:"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "It's nice to see you here learning how to build bots like me. These are things you are currently using here:"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "• Slack Web API \n • Slack App and bot token \n • Slack SDK for node.js \n • Slack Blocks"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Let me send an image as well:"
}
},
{
"type": "image",
"image_url": "https://raw.githubusercontent.com/rod4n4m1/post-blocks/master/ibm-cloud.png",
"alt_text": "inspiration"
}
];
(async () => {
await web.chat.postMessage({
channel: ChannelId,
text: 'CDI',
blocks: MessageBlock
}).catch(function(res){
console.error('Error code: ',res.code);
console.error('Error message: ', res.data.error);
});
})();