MCPcopy
hub / github.com/slackapi/node-slack-sdk / slackSlashCommand

Function slackSlashCommand

examples/express-all-interactions/server.js:217–245  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

215
216// Slack slash command handler
217function slackSlashCommand(req, res, next) {
218 if (req.body.command === '/interactive-example') {
219 const type = req.body.text.split(' ')[0];
220 if (type === 'button') {
221 res.json(interactiveButtons);
222 } else if (type === 'menu') {
223 res.json(interactiveMenu);
224 } else if (type === 'dialog') {
225 res.send();
226 (async () => {
227 try {
228 // Open dialog
229 const response = await web.dialog.open({
230 trigger_id: req.body.trigger_id,
231 dialog,
232 });
233 } catch (error) {
234 axios.post(req.body.response_url, {
235 text: `An error occurred while opening the dialog: ${error.message}`,
236 }).catch(console.error);
237 }
238 })();
239 } else {
240 res.send('Use this command followed by `button`, `menu`, or `dialog`.');
241 }
242 } else {
243 next();
244 }
245}
246
247// Helpers
248function formatNeighborhoodsAsOptions(neighborhoods) {

Callers

nothing calls this directly

Calls 2

nextFunction · 0.85
sendMethod · 0.45

Tested by

no test coverage detected