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

sec-alert-triage-bot

v1.0.0

Published

The awesomest bot evar.

Downloads

3

Readme

easy-peasy-bot

The story of a (Slack)bot

A (not so) long time ago, a team called Tiny Speck built an app to communicate with each other as they worked. In their daily work, they found that there were some mindless tasks they had to do over and over. These things pulled them out of important conversations, which slowed them down.

So, they built a special user in their messaging app: not a human user, but a digital user. The digital user took on some of their mindless tasks and integrated the other apps they used into their conversations.

Eventually their app was named Slack and their digital user, Slackbot. And lo, you can build a Slack Bot, too! With our API and this nifty repository, a bot for your team can be all yours.

Using Botkit for Custom Bots

  1. Fork this project.

  2. Open up your favorite terminal app, and clone your new repository to your local computer.

  3. This is a Node.js project, so you’ll need to install the various dependencies by running: npm install

  4. Edit package.json to give your bot a name and update the GitHub URLs to reflect the location of your fork in GitHub.

  5. Go to https://my.slack.com/apps/new/A0F7YS25R-bots and pick a name for your new bot.

  6. Once you’ve clicked “Add integration,” you’ll be taken to a page where you can further customize your bot. Of importance is the bot token—take note of it now.

  7. Once you have the token, you can run your bot easily:

    TOKEN=xoxb-your-token-here npm start

    Your bot will now attempt to log into your team, and you should be able talk to it. Try telling your new bot “hello”. It should say “Hello!” back!

  8. Botkit is structured around event listeners. The most important is the “hear” listener, which kicks off an action when your bot hears something. index.js contains the core logic, and has this event listener:

    controller.hears('hello','direct_message', function(bot,message) {
        bot.reply(message, 'Hello!');
    });

    This event handler is triggered when the bot receives a direct message from a user that contains the word “hello.”

    The bot responds in the direct message with, “Hello!”

  9. You can listen to any kind of message or you can configure your bot to only listen to direct messages or specific @-mentions of your bot. It’s up to you! To start let’s re-write the event listener to be more flexible about the greetings it is listening for:

    controller.hears(['hello', 'hi', 'greetings'], ['direct_mention', 'mention', 'direct_message'], function(bot,message) {
         bot.reply(message, 'Hello!');
     });

    Now our bot will respond any time it sees “hello,” “hi,” or “greetings” in either a DM or a message that @-mentions the bot. (Don’t forget to restart your bot after each edit!)

Hurrah! Welcome to Level 2

You’ve built your first bot in Slack, and it’s not just a Hello World bot—it’s a Hi World and Greetings World bot too!

At this point you will probably want to start doing more sophisticated things, like making requests to external services, so your bot can respond with timely and useful information (depending on what your bot does, of course). There’s a lot more to Botkit than this! You can learn more about Botkit’s awesome features by simply perusing the Botkit documentation.

Once you’ve got your bot developed to your liking, it is ready to be deployed to your own hosting framework. No other configuration is necessary, except storing the token and desired port in environment variables.

Using Botkit for Bot Apps

You can find full instructions for building a bot app with this repository at https://medium.com/slack-developer-blog/easy-peasy-bots-getting-started-96b65e6049bf#.4ay2fjf32