Skip to content

Instantly share code, notes, and snippets.

@mickmister
Last active June 10, 2024 19:23
Show Gist options
  • Save mickmister/6d1bbcfe386c833ede9fede37525f6f5 to your computer and use it in GitHub Desktop.
Save mickmister/6d1bbcfe386c833ede9fede37525f6f5 to your computer and use it in GitHub Desktop.

You'll need to unmute the video to hear the audio

create-post-with-buttons.mp4
(() => {
const channelId = 'az6sexnys38w58ha4891dq91ho';
const body = {
"channel_id": channelId,
"props": {
"app_bindings": [
{
"label": "",
"description": "",
"location": "embedded",
"app_id": 'my_app_id',
"bindings": [
{
"location": "clickme",
"label": "Yes",
"submit": {
"path": "/path1",
"expand": {
"post": "all"
},
"state":{
'original_post_info': 'data1'
}
}
},
{
"location": "clickme2",
"label": "No",
"submit": {
"path": "/path2",
"expand": {
"post": "all",
"acting_user":"id"
},
"state":{
'original_post_info': 'data2'
}
}
}
]
}
]
}
}
fetch("/api/v4/posts",
{
"headers": {
"accept": "*/*",
"accept-language": "en",
"content-type": "application/json",
"sec-ch-ua": "\"Not)A;Brand\";v=\"24\", \"Chromium\";v=\"116\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"macOS\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-requested-with": "XMLHttpRequest"
},
"referrerPolicy": "no-referrer",
"body": JSON.stringify(body),
"method": "POST",
"mode": "cors",
"credentials": "include"
});
})()
(() => {
const buttons = [
'good',
'warning',
'danger',
'default',
'primary',
'success',
'default',
'#f33',
'#ab4',
'#2334ee',
'buttonBg',
'onlineIndicator',
'dndIndicator',
'',
]
const actions = buttons.map(color => ({
type: 'button',
name: color || 'no styling',
style: color,
}));
const channelId = '67dbk7oy47g8xxhz6hu86gquce';
const body = {
"channel_id": channelId,
"props": {
"attachments": [
{
"color": "#95b7d0",
"text": "",
"actions": [
{
"id": "rdctccrz6ifz7xreh8obgucofy",
"type": "select",
"name": "Transition issue",
"options": [
{
"text": "Reopen",
"value": "Reopened"
}
]
},
...actions,
]
}
]
}
}
fetch("/api/v4/posts",
{
"headers": {
"accept": "*/*",
"accept-language": "en",
"content-type": "application/json",
"sec-ch-ua": "\"Not)A;Brand\";v=\"24\", \"Chromium\";v=\"116\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"macOS\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-requested-with": "XMLHttpRequest"
},
"referrerPolicy": "no-referrer",
"body": JSON.stringify(body),
"method": "POST",
"mode": "cors",
"credentials": "include"
});
})()
(() => {
const channelId = '67dbk7oy47g8xxhz6hu86gquce';
const body = {
"channel_id": channelId,
"props": {
"attachments": [
{
"fallback": "Demo plugin [link](www.test.com)",
"color": "#95b7d0",
"pretext": "Demo plugin [link](www.test.com)"
}
],
"from_bot": "true",
"from_plugin": "true"
}
};
fetch("/api/v4/posts",
{
"headers": {
"accept": "*/*",
"accept-language": "en",
"content-type": "application/json",
"sec-ch-ua": "\"Not)A;Brand\";v=\"24\", \"Chromium\";v=\"116\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"macOS\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-requested-with": "XMLHttpRequest"
},
"referrerPolicy": "no-referrer",
"body": JSON.stringify(body),
"method": "POST",
"mode": "cors",
"credentials": "include"
});
})()
@mickmister
Copy link
Author

mickmister commented Sep 26, 2023

You'll need to unmute the video to hear the audio

create-post-with-buttons.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment