Giter Club home page Giter Club logo

serverless-slack-app's Introduction

Serverless Slack App Boilerplate

Create a serverless Slack App with AWS Lambda, API Gateway, DynamoDB, and CloudFormation. All services will be automatically provisioned for you. All that's needed is your Slack App keys.

Install Serverless and provision AWS

serverless-slack-install

  1. Setup your AWS Credentials
  2. Install Serverless.js
npm install -g serverless
  1. Install The Serverless Slack App Template and provision all AWS services
serverless install --url https://github.com/johnagan/serverless-slack-app
cd serverless-slack-app
npm install
serverless deploy

Create a Slack App

serverless-slack-app

  1. Create a new Slack App
  2. Use the generated POST url for Slack's slash commands, events, and interactive messages
  3. Update the serverless.yml with your new Slack App keys
Slack Serverless
slack-app-keys serverless-keys

Install the Slack App and Test

serverless-slack-app-install

  1. Deploy the changes to AWS serverless deploy
  2. Navigate to the GET url provided from serverless
  3. Walk through the OAuth flow and install the App
  4. Goto the team and test the slash command /greet

Update the Code

// Slash Command handler
slack.on('/greet', (msg, bot) => {
  let message = {
    text: "How would you like to greet the channel?",
    attachments: [{
      fallback: 'actions',
      callback_id: "greetings_click",
      actions: [
        { type: "button", name: "Wave", text: ":wave:", value: ":wave:" },
        { type: "button", name: "Hello", text: "Hello", value: "Hello" },
        { type: "button", name: "Howdy", text: "Howdy", value: "Howdy" },
        { type: "button", name: "Hiya", text: "Hiya", value: "Hiya" }
      ]
    }]
  };

  // ephemeral reply
  bot.replyPrivate(message); 
});


// Interactive Message handler
slack.on('greetings_click', (msg, bot) => {
  let message = { 
    // selected button value
    text: msg.actions[0].value 
  };  

  // public reply
  bot.reply(message);
});
  1. Open the bot source code
  2. Add/Remove/Update the code with your bot functionality
  3. Run serverless deploy to deploy your changes to AWS
  4. Rinse and repeat.

All the tokens and urls above were invalidated before posting this tutorial. You will need to use your own tokens

serverless-slack-app's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.