Incoming Webhooks
外部appからSlackの特定channelにメッセージを投稿できる機能
使い方
3. 生成したURLにPOSTすれば使える
API keyや認証の類は必要ない
テストコード
https://hooks.slack.com/services/xxxxxx/yyyyyy/zzzzzzに各自で発行したwebhook URLを入れる
cURL
code:bash
curl -X POST -H 'Content-type: application/json' --data '{"blocks":[{"type":"header","text":{"type":"plain_text","text":"New request"}},{"type":"section","fields":{"type":"mrkdwn","text":"*Type:*\nPaid Time Off"},{"type":"mrkdwn","text":"*Created by:*\n<example.com|Fred Enriquez>"}},{"type":"section","fields":{"type":"mrkdwn","text":"*When:*\nAug 10 - Aug 13"}},{"type":"section","text":{"type":"mrkdwn","text":"<https://example.com|View request>"}}]}' https://hooks.slack.com/services/xxxxxx/yyyyyy/zzzzzz Deno
code:js
code:script.js
const body = {
blocks: [
{
type: "header",
text: {
type: "plain_text",
text: "New request"
},
},
{
type: "section",
fields: [
{
type: "mrkdwn",
text: "*Type:*\nPaid Time Off"
},
{
type: "mrkdwn",
text: "*Created by:*\n<example.com|Fred Enriquez>"
}
],
},
{
type: "section",
fields: [
{
"type": "mrkdwn",
"text": "*When:*\nAug 10 - Aug 13"
}
]
},
{
type: "section",
text: {
type: "mrkdwn",
}
}
]
}
await fetch(url, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body,
});
bash.icon
Deno.icon