{"id":19365707,"url":"https://github.com/ryanleecode/slackpay","last_synced_at":"2025-08-25T23:04:12.428Z","repository":{"id":92609830,"uuid":"118218370","full_name":"ryanleecode/SLACKPAY","owner":"ryanleecode","description":null,"archived":false,"fork":false,"pushed_at":"2018-01-21T13:04:45.000Z","size":90,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-19T03:41:28.565Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanleecode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-20T07:06:13.000Z","updated_at":"2018-01-20T07:10:59.000Z","dependencies_parsed_at":"2023-03-02T10:15:58.002Z","dependency_job_id":null,"html_url":"https://github.com/ryanleecode/SLACKPAY","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ryanleecode/SLACKPAY","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanleecode%2FSLACKPAY","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanleecode%2FSLACKPAY/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanleecode%2FSLACKPAY/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanleecode%2FSLACKPAY/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanleecode","download_url":"https://codeload.github.com/ryanleecode/SLACKPAY/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanleecode%2FSLACKPAY/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272144649,"owners_count":24881141,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T07:41:58.854Z","updated_at":"2025-08-25T23:04:12.398Z","avatar_url":"https://github.com/ryanleecode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Your StdLib Slack App\n\nWelcome to your StdLib Slack template!\n\nIf you're not sure what StdLib (\"Standard Library\") is, please check out\nhttps://stdlib.com.\n\nHere we'll walk you through how StdLib works, your Slack App endpoints,\nand how to handle Slack Slash Commands, Events, and Actions from interactive\nmessages.\n\n# Your Project\n\nThe first thing you'll probably notice is your `functions/` directory. This is\nyour StdLib function directory which maps directly to HTTP endpoints. There are\nfive main functions in your Slack App:\n\n- `__main__.js`\n- `auth.js`\n- `commands/__main__.js`\n- `events/__main__.js`\n- `actions/__main__.js`\n\nWe'll go through these in the order listed here.\n\n## Function: `functions/__main__.js`\n\nThis is your main endpoint, corresponding to `https://username.lib.id/service/`.\nThis is, of course, where `username` is your username and `service` is your service\nname.\n\nAny time a function has the filename `__main__.js`, the enclosing folder is\nused as the route name over HTTP. You can think of it like the default function\nfor a specific directory.\n\nNote that when pushing to a development environment (or if you want to access\n  a specific version), this should be reached via:\n  `https://username.lib.id/service@dev/main` (if your dev environment is called\n  `dev`, also the default local environment name) or\n  `https://username.lib.id/service@0.0.0/main` (if your version is 0.0.0).\n\n### Usage\n\nThis endpoint generates a template based on the contents of `pages/index.ejs`,\nwhich is modifiable and contains your \"Add to Slack\" button. It is the easiest\nway to distribute your app to other users.\n\n## Function: `functions/auth.js`\n\nThis is the OAuth endpoint for your Slack App that verifies another team (or your\n  own) has properly validated the slack app.\n\n### Usage\n\nThis endpoint processes an OAuth request and returns the contents of\n`slack/pages/auth.ejs`. (Typically \"Success!\" if successful.)\n\n## Function: `functions/commands/__main__.js`\n\nThis is the main **Command Handler** function for handling Slack Slash Commands.\nYou can read more about them here: https://api.slack.com/slash-commands\n\nThis function is triggered by slack at the following URL:\n`https://\u003cusername\u003e.lib.id/\u003cservice\u003e@\u003cver\u003e/commands/:bg`\n\nWhere `\u003cusername\u003e` is your username, `\u003cservice\u003e` is the service name and\n`\u003cver\u003e` is the environment or semver release of your service. The `:bg`\nindicates you'd like this function to return an HTTP 2XX code as quickly as\npossible and do all processing behind the scenes. (Ideal for Slack.)\n\n### Usage\n\nTo add or modify Slash commands, you'll want to look in the directory\n`functions/commands/` and create files with the name\n`functions/commands/NAME.js` where `NAME` is your intended command,\nand also add them to your Slash Commands list via Slack's Slash Command interface.\n\nFor the default \"hello\" command (should be added as `/hello` to your app) you'll\nnotice the following boilerplate code:\n\n```javascript\nmodule.exports = (user, channel, text = '', command = {}, botToken = null, callback) =\u003e {\n\n  callback(null, {\n    response_type: 'in_channel',\n    text: `Hello, \u003c@${user}\u003e...\\nYou said: ${text}`\n  });\n\n};\n```\n\nIn this function, `user` and `channel` are strings representing the user and\nchannel the command was called from. The contents of the command (text) are\navailable in `text`, a full `command` object is available\nthat contains all data passed from slack (https://api.slack.com/slash-commands),\nand a botToken for your Slack App's bot is passed in (if you want to use it\n  to post additional messages, upload files, etc.).\n\nThe first parameter passed to `callback` is an error (if present), use `new Error()`\nwhen possible. The second parameter is a `chat.postMessage` object,\nmore details can be found here: https://api.slack.com/methods/chat.postMessage.\n\nYou can test the sample hello command on the command line by running\n\n```shell\n$ lib .commands.hello test_user general \"some text\"\n```\n\n## Function: `functions/events/__main__.js`\n\nThis is the main **Event Handler** function for handling public channel events\nfrom Slack's Event API: https://api.slack.com/events\n\nThis function is triggered by slack at the following URL:\n`https://\u003cusername\u003e.lib.id/\u003cservice\u003e@\u003cver\u003e/events/:bg`\n\nWhere `\u003cusername\u003e` is your username, `\u003cservice\u003e` is the service name and\n`\u003cver\u003e` is the environment or semver release of your service. The `:bg`\nindicates you'd like this function to return an HTTP 2XX code as quickly as\npossible.\n\nYou'll notice an `* @bg params` line in the comments for this function. This\nmeans, when executed as a background function, it will return a JSON object\nmapping to the parameters passed to it (which also passes Slack's `challenge`\nlitmus test).\n\n### Usage\n\nThis function will delegate incoming events to their appropriate handler,\nwhich can be placed in `functions/events/TYPE.js` or `functions/events/TYPE/__main__.js`\nas these are functionally equivalent. If there is a subtype involved,\n`functions/events/TYPE/SUBTYPE.js` or `functions/events/TYPE/SUBTYPE/__main__.js`\nwill be invoked.\n\nBy default your `functions/events/message/__main__.js` should look like this:\n\n```javascript\nmodule.exports = (user, channel, text = '', event = {}, botToken = null, callback) =\u003e {\n\n  // Only send a response to certain messages\n  if (text.match(/hey|hello|hi|sup/i)) {\n    callback(null, {\n      text: `Hey there! \u003c@${user}\u003e said ${text}`\n    });\n  } else {\n    callback(null, {});\n  }\n\n};\n```\n\nIn this function, `user` and `channel` are strings representing the user and\nchannel the event was triggered by. The contents of the command (text) are\navailable in `text`, a full `event` object is available\nthat contains all data passed from slack (https://api.slack.com/events),\nand a `botToken` for your Slack App's bot is passed in (if you want to use it\n  to post additional messages, upload files, etc.).\n\nThe first parameter passed to `callback` is an error (if present), use `new Error()`\nwhen possible. The second parameter is a `chat.postMessage` object,\nmore details can be found here: https://api.slack.com/methods/chat.postMessage.\n\nYou can test the sample message event on the command line by running:\n\n```shell\n$ lib .events.message test_user general \"hello\"\n```\n\n## Function: `functions/actions/__main__.js`\n\nThis is the main **Action Handler** function for handling Slack Actions from\ninteractive messages. You can read more about actions and interactive messages\nhere: https://api.slack.com/docs/message-buttons.\n\nThis function is triggered by slack at the following URL:\n`https://\u003cusername\u003e.lib.id/\u003cservice\u003e@\u003cver\u003e/actions/:bg`.\nYou should add this URL to the interactive messages section of your Slack app\ndashboard.\n\nWhere `\u003cusername\u003e` is your username, `\u003cservice\u003e` is the service name and\n`\u003cver\u003e` is the environment or semver release of your service. The `:bg`\nindicates you'd like this function to return an HTTP 2XX code as quickly as\npossible.\n\n### Usage\n\nThis function will delegate incoming actions to their appropriate handler,\nwhich should be placed in `functions/actions/NAME.js`.\n\nWe've included a simple sample handler for an action named `example`. The code\nfor this is below:\n\n```javascript\nmodule.exports = (user, channel, action = {}, botToken = null, callback) =\u003e {\n\n  callback(null, {\n    text: `Hello, \u003c@${user}\u003e!\\nThis text will overwrite the original interactive message`,\n    attachments: [{\n      text: 'Try hitting this endpoint again by clicking the button!',\n      fallback: 'Can\\'t display attachment',\n      callback_id: 'callback_id',\n      actions: [\n        {\n          name: 'example',\n          text: 'Refresh',\n          type: 'button',\n          value: 'value'\n        }\n      ]\n    }]\n  });\n\n};\n```\n\nIn this function, `user` and `channel` are again strings representing the user\nand channel the event was triggered by. A full `action` object is available\nthat contains all data passed from Slack\n(https://api.slack.com/docs/interactive-message-field-guide#action_payload),\nand a `botToken` for your Slack App's bot is passed in (if you want to use it\n  to post additional messages, upload files, etc.).\n\nThe first parameter passed to `callback` is an error (if present), use `new Error()`\nwhen possible. The second parameter is a `chat.updateMessage` object,\nmore details can be found here: https://api.slack.com/methods/chat.update.\n\nWhatever you choose to return in the second callback parameter will\n__overwrite__ the original message. This parameter could be a confirmation\nmessage or another call to action. This value can be a simple string or an\nobject that conforms to the spec set in `chat.update`\n(see https://api.slack.com/methods/chat.update. We automatically\nattach the token, ts, and channel params for you outside of this handler). You\ncan also restore the original message in case of an error by returning Slack's\n`original_message` parameter, which will be present in the `action` parameter.\n\nYou could create a interactive message that would trigger this handler with the\nfollowing Javascript code (you will have to run `npm install slack --save`\nfirst):\n\n```javascript\nconst slack = require('slack');\n\nslack.chat.postMessage({\n token: process.env.BOT_TOKEN,\n channel: '#general',\n text: 'Respond to this',\n attachments: [{\n   text: 'Here is the action:',\n   actions: [\n     {\n       name: 'example',\n       text: 'Press me',\n       type: 'button'\n     }\n   ]\n }]\n}, (err, result) =\u003e {\n // Handle result\n});\n```\n\nYou can retrieve your bot token from the OAuth and Permissions section of your\nSlack dashboard.\n\nAdditionally, you can test the example action locally from your command line by\nrunning:\n\n```shell\nlib .actions --action example --channel general --user user\n```\n\n**Note:** Your action handlers will only work with messages created via the\n`slack.chat.postMessage` API call.\n\n# Utilities\n\nThis Slack App template comes with some utility function in `slack/utils`.\nWe'll go over a few of them;\n\n- message.js\n- update_message.js\n- respond.js\n- upload.js\n\n## Utility: `utils/message.js`\n\nThis function has a fingerprint of:\n\n```javascript\nmodule.exports = (token, channel, text, callback) =\u003e {}\n```\n\nWhere `token` is your bot token (the token used for the bot response),\n`channel` as the channel where the response is expected, `text` being a\nstring or `channel.postMessage` object (for more granular control),\nand `callback` being a function expecting one parameter (an `error`, if applicable)\nthat executes the call.\n\nUse this function to get your bot to send messages to users or channels --- that's\nit. The `token` field should be passed in any `slack/commands` or `slack/events`\nhandlers.\n\n## Utility: `utils/update_message.js`\n\nThis function has a fingerprint of:\n\n```javascript\nmodule.exports = (token, channel, ts, message, callback) =\u003e {}\n```\n\nWhere `token` is your bot token (the token used for the bot response),\n`channel` as the channel where the response is expected, `ts` as the timestamp\nof the message being updated, `message` being a string or `chat.update` object\n(for more granular control) that will replace the original message, and\n`callback` being a function expecting one parameter (an `error`, if applicable)\nthat executes the call.\n\nUse this function to get your bot to update messages in channels.\n\n## Utility: `utils/respond.js`\n\nVery similar to `message.js`, this is a Slash Command response that `HTTP POST`s\na message to a webhook endpoint instead of creating a new bot message directly.\n\nThe benefits this has over `message.js`, is that Slash Commands can be used in\nprivate channels (or globally, within a team) where applicable.\n\n## Utility: `utils/upload.js`\n\nSimilar to `message.js`, this function has a fingerprint of:\n\n```javascript\nmodule.exports = (token, channel, filename, contentType, file, callback) =\u003e {}\n```\n\nWhere `token` is your bot token, `channel` is the channel to upload a file to,\n`filename` is the desired filename, `contentType` is the desired content type\n(i.e. a string like `image/png`), file is a `Buffer` of file contents\nand `callback` is a function that can handle an optional `err` parameter.\n\n# Helpers\n\nThere are a few helper functions for message formatting, etc. Feel free to\nlook at them at your leisure, we've documented `storage.js` to better understand\nhow team data is stored.\n\n## Helper: `helpers/storage.js`\n\nThis is a storage helper based upon https://stdlib.com/utils/storage. It\nis a basic key-value store that saves crucial team (including bot) details\nabout each and every team its installed on, specific to the `SLACK_APP_NAME`\nfield in your `env.json` and your StdLib (https://stdlib.com) account. You\nshould probably avoid interfacing with this function directly, but it should\nbe noted that it is *critical* for the ability to install your app on\nmultiple teams.\n\n# That's it!\n\nWe hope this has served as a welcoming introduction to your\nSlack App project scaffold on [StdLib](https://stdlib.com) --- happy building!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanleecode%2Fslackpay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanleecode%2Fslackpay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanleecode%2Fslackpay/lists"}