Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Command Everything With a Serverless Slack Bot

DZone's Guide to

Command Everything With a Serverless Slack Bot

The boom of chatbots has brought a lot of discussion on their future and the tasks they will ultimately replace. They even have a place in DevOps

· DevOps Zone
Free Resource

Learn more about how CareerBuilder was able to resolve customer issues 5x faster by using Scalyr, the fastest log management tool on the market. 

Image title

The boom of chatbots has spurred discussion about the role they'll play and tasks they will ultimately replace. At Librato, we’ve always been fans of bots. For example, we’ve adopted the chat bot Lita to help us with alert management, server monitoring, code deployment, and other repetitious tasks.

Recently, a wave of new bots have been introduced to Slack, including serverless bots which allow you to quickly get set up without worrying about hosting or excessive configuration. Let’s take a look at one of our favorite serverless bots, Nestor, which provides tons of power and can be set up in minutes.

Nestor is a hosted chatbot that enables communication with services like GitHub, Heroku, Trello, Papertrail, Librato, Mixpanel, MailChimp, and more. Setup is as simple as selecting the services you use (you can use up to 5 integrations for free) and providing each service with an API token.

Installing Nestor on Slack

Head over to the Nestor homepage and sign up with your Slack account. Once connected, you will see Nestorbot pop up in your Slack messages with some basic instructions.

View your pre-installed powers (aka integrations) with the command `@nestorbot: my powers`. If you need to remove any powers, simply use the command `@nestorbot: remove <power name>`. And, to see what functions a specific power offers, you can run the command ‘@nestorbot <power name> help’.

Nestor Meets Librato

Let’s set up the Librato power and take a look at what it can do. Install the Librato power with the following command:

 @nestorbot: add librato 

Once installed, you’ll receive a response from Nestor asking you to setup the Librato API token. In your Librato account, you’ll need to create an API token for Nestor. From there you will need to provide these credentials to Nestor over Slack:

 @nestorbot NESTOR_LIBRATO_USER="<your librato email>" 
 @nestorbot NESTOR_LIBRATO_TOKEN="<your token>" 

If all goes smoothly you should be able to send Librato commands to Nestor. Send the message  @nestorbot librato spaces  to view your account’s Spaces:

Nestor-Librato


Display a chart within a Space with the following command:

 @nestorbot graph me space <Chart Name> space <Space Name> 

router-queue-time

A useful situation where the Librato integration comes into play is responding to alerts. Librato offers unlimited alerts on your metrics, which you can receive via Slack, PagerDuty, email, text, etc.

Say you have an alert to notify you whenever your app returns a 404 or 500 error. You can take action by using Nestor to view the chart which triggered the error:

 @nestorbot graph me HTTP Status Codes space Heroku Overview 

HTTP-Status-Codes-graph

Pro tip: if you think you’re going to use this command often, create an alias:

 @nestorbot set alias htttpcodes=HTTP Status Codes space Heroku Overview 

Now you can obtain the same graph by typing  @nestorbot httpcodes .

Nestor Me Some Logs

Need to view the logs to get more info? Setup Papertrail with your app and enable the integration with Nestor:

 @nestorbot add papertrail 

Once set up, you can quickly view your logs which match the error in question:

 @nestorbot papertrail me status=500 

papertrail-status-500


Take Nestor to the Next Level

Now that you can quickly access your charts and logs, what’s next? You can add additional functionalities to an integration or create a new power by following the Nestor developer guide. If you want to develop new commands for Nestor’s Librato integration, take a look at our API docs. We’d love to see community contributions for the Librato power on Github.

Not a Librato customer? No problem. The trial is full-featured and free for 30 days. 

Find out more about how Scalyr built a proprietary database that does not use text indexing for their log management tool.

Topics:
slack ,bots ,serverless ,command ,librato

Published at DZone with permission of Greg McKeever, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}