npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-slack

v1.0.27

Published

A Slack App Framework for AWS Lambda / Serverless.js

Downloads

48

Readme

Serverless Slack

This is a micro-framework designed to create Slack Apps with serverless.js.

Demonstration

A complete template and tutorial can be found at johnagan/serverless-slack-app.

API

Events

// handle RTM messages
slack.on('message', (payload, bot) => { });

// handle all slash commands
slack.on('slash_command', (payload, bot) => { });

// handle the outgoing webhooks trigger word "googlebot"
slack.on('googlebot', (payload, bot) => { });

// wildcard support
slack.on('*', (payload, bot) => { });

Event | Description :---|:--- * | All events message | All RTM events slash_command | All Slash Commands event | All Event API callbacks webhook | All WebHook callbacks interactive_message | All Interactive message callbacks [/command] | Any specific slash command [event type] | Any specific event type [trigger word] | Any trigger from outgoing webhooks

Bot

Bots are preloaded with the appropriate token and are context aware. So you can reply to messages and send ephemeral updates to a message.

slack.on('message', (payload, bot) => {
  bot.replyPrivate('loading...');

  bot.reply({
    text: 'Everything is working!',
    attachments: [{
      title: "Slack API Documentation",
      title_link: "https://api.slack.com/",
      text: "Optional text that appears within the attachment",
      fields: [{
        title: "Priority",
        value: "High",
        short: false
      }]
    }]
  });

  // the token is already set
  bot.send('channels.info', { channel: 'C1234567890' }).then(data => {
    // results from API call
  });
});

Methods | Description :---|:--- say | Send a message reply | Send a public reply to the event replyPrivate | Send an ephemeral reply to the event send | Call any Slack API endpoint

Data Store

A key/value store to maintain team/bot information and store custom setings. The store should contain a uniquie id field.

slack.store.save(data).then(results => {
  // the save results
});

slack.store.get(id).then(record => {
  // return a single record by key
});

Methods | Description :---|:--- get | Get a single record by id all | Get all saved records save | Save a record

Client

The Slack client is a way to call the API outside of an event.

let message = {
  unfurl_links: true,
  channel: 'C1QD223DS1',
  token: 'xoxb-12345678900-ABCD1234567890',
  text: "I am a test message http://slack.com",
  attachments: [{
    text: "And here's an attachment!"
  }]
}

// send message to any Slack endpoint
slack.send('chat.postMessage', message).then(data => {
  // Success!
});

// respond to webhooks
slack.send('https://hooks.slack.com/services/T0000/B000/XXXX', message);