Coded Geekery

BlogWritingAboutContact
BlogWritingAboutContact

Slack

Create a slash command.

export default (req, res) => { const { token, text } = req.body; if (token !== process.env.SLACK_TOKEN) { return res.status(400); } const textUrl = text && `/says/${text}`; return res.status(200).json({ response_type: 'in_channel', text: `https://cataas.com/cat${textUrl}` }); };

Usage#

  • Create a Slack App

  • First, create a Slack app.

    If you don't have an organization yet, you'll also need to create one.

  • Add Slash Command

  • With your app created, you can define a slash command.

    1. Navigate to "Slash Commands" and click "Create New Command".
    2. Fill out the form using the deployed URL for your function.
    3. Hit "Save".
  • Add To Workspace

  • Navigate back to "Basic Information" click "Install App to Workspace". Make note of the Verification Token. We need to add this as an environment variable.

  • Add Environment Variable

  • To securely access the API, we need to include the secret with each request.

    Remember: never commit secrets to git. Thus, we should use an environment variable.

    Not Playing

    Spotify

    Coded Geekery

    TwitterGitHubInstagramgumroadbuymeacoffee

    Stuff

    HomeAbout MeContact Me

    © 2022 Roger Stringer. All rights reserved.