Using Lookerbot for Slack

low_priority
done
reply
#1

Lookerbot for Slack integrates with Looker to allow you to query all of your data directly from Slack. This enables everyone in your company to share data easily and answer data-driven questions instantly. Lookerbot can expand Looker URLs and allows you to create custom commands for running saved queries.

Find technical details for setting up Lookerbot here.

Expanding Looker URLs

If Lookerbot is added to a channel and the LOOKER_SLACKBOT_EXPAND_URLS variable is set to true, Lookerbot will expand share URLs and Look URLs. If the explore has an associated visualization, it will show an image of that visualization. If the explore is a table, it will show the data as text.

For example, these two URLs will expand like so:

https://learnbeta.looker.com/x/3Hq6Q2j  # share URL
https://learnbeta.looker.com/looks/263  # Look URL

Custom Commands

Lookerbot also allows you to create custom commands for running saved queries. This allows you to easily run common queries and answer frequent questions!

Creating Commands

In order to create custom commands, make sure to specify a custom command space using the LOOKER_CUSTOM_COMMAND_SPACE_ID variable during setup. Any dashboard saved in this Space will be available to use as a command.

To create a new command:

  1. Create a dashboard with a single element in the Lookerbot commands space. Only dashboards with single elements can currently be used with the Lookerbot.

  2. Give the dashboard a discoverable name - the name of the dashboard will be the name of the command. I recommend fewer letters and all lowercase for ease of use.

  3. Add global filters to the dashboard in order to pass filter values to the command. Read about how to add filters to a dashboard in Looker here. (optional)

  4. Add a description to the dashboard - this will appear next to the command when a user types help. (optional)

If you’d like to split commands up into logical groups, you can create subspaces within the Lookerbot command space. This will group the commands in the help list.

In order to see all the available commands, type help to Lookerbot (see how to do this below). This will give you a list like so:

Using Commands

Use a command by typing the name of the command, followed by any filter values you want to add. Filters are optional, and the query will run without that filter if no values are specified.

For example, I can run the customer map in command, filtered for New York like so:

There are three ways to use commands:

  1. @mention Lookerbot. This can be done in any channel Lookerbot is present in.

  2. Use the slash command. This can be done if the slash command has been configured during set up.

  3. Direct message Lookerbot. If you send a message directly to Lookerbot, you don’t need to prepend the command with anything.

Data formats

Commands will also return data in different ways, depending on the visualization type of the underlying Look. There are three possible return formats:

  1. Text: If the underlying Look is a table, the data will return as text

  2. Single Value Text: If the underlying Look is a Single Value visualization, the data will return as a text value

  3. Image: If the underlying Look is a chart, the data will return as a image of the visualization

Hiding commands and subspaces

If you have some commands that you don’t want to appear in the help menu, but you still want to use with Lookerbot, you can hide either the command or the entire subspace the command is saved in. Hide a command or subspace by starting the name with [Hidden].

For example, this subspace and this command will not be visible in the help menu:

8 Likes

Looker 3.42 Release Notes
(Cliftonc) #2

Looks great - are you building one for Hipchat?

2 Likes

(Mark Brown) #3

Have you tried running this in AWS Lambda yet? You wouldn’t need a server then if it works.

1 Like

(Lawrence) #4

+1 for a Hipchat bot

2 Likes

(Jon Coe) #5

@Mark_Brown what would you see as the event source to the Lambda?

0 Likes

(Mark Brown) #6

API gateway to expose it as a service I suppose. I haven’t had a chance to look yet. I used lambda when playing around with the Looker API. I used the API gateway to call a lambda function that made requests to the Looker API. It had a bit of lag but worked fine to get data and display it in a simple nvd3 chart.

0 Likes

(Jon Coe) #7

My point of concern was that (unless i misunderstand), a slackbot needs to listen - there isn’t any process for sending it an event. It listens to the channel(s) it belongs to.

I’m a big Lambda advocate: have used it successfully and surprisingly smoothly with both API Gateway and Kinesis stream as sources. That being said, I don’t see a way for it to work here without an additional process to listen to the channel and send the events to API Gateway or whatever. The cost of that is, in my mind, more than that of running a server for the bot itself (which is tailor-made for listening to slack channels).

0 Likes

(Wil Gieseler) #8

I am not particularly familiar with Lambda, but the bot could be made to operate in a mode where it does not attempt to do any listening and only responds to Slash commands (which are POSTs to a web server running on the bot).

Looks like there’s some prior art here: http://www.ryanray.me/serverless-slack-integrations

0 Likes

#9

Does a query rerun when the Slack page is reloaded, or is it run only when the Slack user initially calls for it?

0 Likes

(Wil Gieseler) #10

We run the query only when you originally ask for the data.

One exception is when expanding links for Looks that are public and have visualizations, we use the static public Look embed mechanism.

0 Likes

(Daniel Weitzenfeld) #11

Now that Version 0.0.3 is out - is there an easy way to update? I’m using Heroku as per the docs.

0 Likes

(Erin Breen) #12

+1 Lookerbot for HipChat!

0 Likes

(Wil Gieseler) #13

Unfortunately the Heroku Button doesn’t offer an easy way to update the app once it’s deployed. I’ve filed a feature request with Heroku to improve this.

Currently the easiest way to upgrade the bot is like this:

  1. Install the Heroku Toolbelt
  2. In the Terminal, log into the Heroku tools:
    heroku login
  3. Clone your Heroku app locally:
    heroku git:clone -a your-heroku-app-name
  4. Move into the newly cloned app:
    cd your-heroku-app-name
  5. Add the looker-slackbot Git remote:
    git remote add origin https://github.com/looker/looker-slackbot.git
  6. Pull the new changes from GitHub to your local repository:
    git pull origin master
  7. Push and deploy the new changes to Heroku:
    git push heroku master
0 Likes

Slack Lookerbot out of date error
(Jamie Wilkinson) #14

Are there any good hacks for staying on Hobbyist Heroku tier but keeping the dynos active during business hours? We keep needing to restart the bot due to idling

0 Likes

(Tig Newman) #15

In Lookerbot’s help menu listing the available commands, you can get a description of the dashboard that gets returned. To do this:

  1. In Looker, navigate to the dashboard.
  2. If you are using dashboard locks, unlock the dashboard.
  3. Click the dashboard’s gear and choose Edit Dashboard Settings.
  4. In the Description field, enter the description you want to appear in the Lookerbot help menu.
  5. Click Save.
  6. If you are using dashboard locks, lock the dashboard.
0 Likes

(Maximilian Roos) #16

xref https://discourse.looker.com/t/hosted-slack-lookerbot/2334

0 Likes

(Stipoj) #17

This is super helpful, Wil. We’ve been using the bot for a few days now and ran into this issue, with confusion, because I wasn’t the one who set the server up.

0 Likes

(Jhonny Fdo Lopez) #18

Hello Wilg

I am excited about the potential of this integration, however has not been possible to make it effective, we follow the steps that indicate the readme, but both heroku, and local environment have the same answer: “Can not GET /”. We think that if it works in the local environment, deploy to Heroku can be manageable, however localhost: 5000, we have the same result, if someone who has been successful in the looker-slack connection, we can help or recommend a solution we were immensely grateful.

Attached is the log of npm in the local environment:

Scuti:looker-slackbot jhofeloto$ heroku local
[OKAY] Loaded ENV .env File as KEY=VALUE Format
10:16:09 AM web.1 | > looker-slackbot@0.0.4 start /Users/jhofeloto/Proyectos/looker-slackbot
10:16:09 AM web.1 | > coffee lib/bot.coffee
10:16:10 AM web.1 | Using Looker information specified in individual environment variables.
10:16:10 AM web.1 | info: ** No persistent storage method specified! Data may be lost when process shuts down.
10:16:10 AM web.1 | info: ** Setting up custom handlers for processing Slack messages
10:16:11 AM web.1 | info: ** API CALL: https://slack.com/api/rtm.start
10:16:11 AM web.1 | info: ** API CALL: https://slack.com/api/team.info
10:16:11 AM web.1 | info: ** Starting webserver on port 5000
10:16:11 AM web.1 | info: ** Serving webhook endpoints for Slash commands and outgoing webhooks at: http://MY_HOST:5000/slack/receive
10:16:11 AM web.1 | info: Warning: using temporary storage. Data will be lost when process restarts.
10:16:11 AM web.1 | Saved the team information…
10:16:11 AM web.1 | notice: ** BOT ID: jhofeloto …attempting to connect to RTM!
10:16:11 AM web.1 | Updated API token for https://argus.looker.com:19999/api/3.0
10:16:11 AM web.1 | Refreshing custom commands for https://argus.looker.com…

Thanks in advance, excuse me for my English are from Colombia :wink:

0 Likes

(Wil Gieseler) #19

The log looks correct to me. Visiting the bot server’s root URL ( /) will indeed show the error Cannot GET / as it does not respond on that URL.

The bot should be running and available online in Slack at this point. There’s no need to visit the bot server via the web.

The only URL the web server responds to is /slack/receive which can be optionally configured if you’d like to set up slash commands.

0 Likes

(Jhonny Fdo Lopez) #20

Wilg

Thank you very much, and we solved, our mistake was that we were using the API WEB TOKEN (https://api.slack.com/web) of SLACK instead of which we provided the BOT SLACK, this confusion was generating the impossibility of connection. And we change and everything worked perfectly.

Thank you!

0 Likes