-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from slackapi/granular_bot_permissions
Granular bot permissions
- Loading branch information
Showing
7 changed files
with
199 additions
and
204 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const axios = require('axios'); | ||
const qs = require('querystring'); | ||
const apiUrl = 'https://slack.com/api'; | ||
|
||
const callAPIMethod = async (method, payload) => { | ||
let data = Object.assign({ token: process.env.SLACK_ACCESS_TOKEN }, payload); | ||
let result = await axios.post(`${apiUrl}/${method}`, qs.stringify(data)); | ||
return result.data; | ||
} | ||
|
||
module.exports = { | ||
callAPIMethod | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
module.exports = { | ||
confirmation: context => { | ||
return { | ||
channel: context.channel_id, | ||
text: 'Helpdesk ticket created!', | ||
blocks: JSON.stringify([ | ||
{ | ||
type: 'section', | ||
text: { | ||
type: 'mrkdwn', | ||
text: '*Helpdesk ticket created!*' | ||
} | ||
}, | ||
{ | ||
type: 'divider' | ||
}, | ||
{ | ||
type: 'section', | ||
text: { | ||
type: 'mrkdwn', | ||
text: `*Title*\n${context.title}\n\n*Description*\n${context.description}` | ||
} | ||
}, | ||
{ | ||
type: 'context', | ||
elements: [ | ||
{ | ||
type: 'mrkdwn', | ||
text: `*Urgency*: ${context.urgency}` | ||
} | ||
] | ||
} | ||
]) | ||
} | ||
}, | ||
modal: context => { | ||
return { | ||
trigger_id: context.trigger_id, | ||
view: JSON.stringify({ | ||
type: 'modal', | ||
title: { | ||
type: 'plain_text', | ||
text: 'Submit a helpdesk ticket' | ||
}, | ||
callback_id: 'submit-ticket', | ||
submit: { | ||
type: 'plain_text', | ||
text: 'Submit' | ||
}, | ||
blocks: [ | ||
{ | ||
block_id: 'title_block', | ||
type: 'input', | ||
label: { | ||
type: 'plain_text', | ||
text: 'Title' | ||
}, | ||
element: { | ||
action_id: 'title', | ||
type: 'plain_text_input' | ||
}, | ||
hint: { | ||
type: 'plain_text', | ||
text: '30 second summary of the problem' | ||
} | ||
}, | ||
{ | ||
block_id: 'description_block', | ||
type: 'input', | ||
label: { | ||
type: 'plain_text', | ||
text: 'Description' | ||
}, | ||
element: { | ||
action_id: 'description', | ||
type: 'plain_text_input', | ||
multiline: true | ||
}, | ||
optional: true | ||
}, | ||
{ | ||
block_id: 'urgency_block', | ||
type: 'input', | ||
label: { | ||
type: 'plain_text', | ||
text: 'Importance' | ||
}, | ||
element: { | ||
action_id: 'urgency', | ||
type: 'static_select', | ||
options: [ | ||
{ | ||
text: { | ||
type: "plain_text", | ||
text: "High" | ||
}, | ||
value: "high" | ||
}, | ||
{ | ||
text: { | ||
type: "plain_text", | ||
text: "Medium" | ||
}, | ||
value: "medium" | ||
}, | ||
{ | ||
text: { | ||
type: "plain_text", | ||
text: "Low" | ||
}, | ||
value: "low" | ||
} | ||
] | ||
}, | ||
optional: true | ||
} | ||
] | ||
}) | ||
} | ||
} | ||
} |
Oops, something went wrong.