Lookerbot for Slack integrates with Looker so that you can query all your data directly from Slack, allowing everyone in your company to share data easily and answer data-driven questions instantly. Lookerbot can automatically expand Looker URLs. You can also create custom commands to run saved queries.
The Lookerbot requires some technical setup before you can work with it in Slack.
Expanding Looker URLs
If Lookerbot is added to a channel and the
LOOKER_SLACKBOT_EXPAND_URLS variable is set to
true, Lookerbot will automatically expand shared 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
Expanding Looker URLS is not available in Direct Messages, because of the distinction made between private/public channels and direct messages in the legacy unfurling API capabilities used in Lookerbot.
Lookerbot also allows you to create custom commands for running saved queries. This allows you to easily run common queries and answer frequent questions!
Slash commands are not required to interact with the bot. To use all of the bot's functionality, you can also message the bot directly or mention the bot in a Slack channel in which the Lookerbot is present:
- Go to https://api.slack.com/apps.
- Choose Slash Commands and click Create New Command.
- Create a command to use for the Looker bot. For example, Looker uses
/lookerfor our internal Slack.
- Set the URL to wherever you have your bot server hosted (if you used Heroku to set up the server, this will be the unique app name that you chose). The path to the slash command endpoint is
/slack/receive, so if your server is at https://example.com, the URL would be https://example.com/slack/receive.
- Under Settings, choose Install App again, then Reinstall App and authenticate.
- Under Basic Information, grab the verification token. You'll use this to set the SLACK_SLASH_COMMAND_TOKEN environment variable.
Creating Custom Commands
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:
- Create a dashboard with a single element in the Lookerbot commands space. Only dashboards with single elements can currently be used with the Lookerbot.
- Give the dashboard a discoverable name. The name of the dashboard will be the name of the command. We recommend using only a few lowercase letters for ease of use.
- Add dashboard filters to pass filter values to the command if necessary.
- Optionally, add a description to the dashboard. This will appear next to the command when a user types
If you would like to split up commands into logical groups, you can create subspaces within the Lookerbot command space. This will group the commands in the help list.
You use a command by typing the name of the command, and then 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, we can run the
customer map in command, filtered for New York like so:
There are three ways to use commands:
- @mention Lookerbot. This can be done in any channel in which Lookerbot is present.
- Use the slash command. This can be done if the slash command has been configured during set up.
- Direct message Lookerbot. If you send a message directly to Lookerbot, you don't need to prepend the command with anything.
Commands will eturn 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 you do not want to appear in the
help menu but that you still want to use with Lookerbot, you can hide either the command or the entire subspace in which the command is saved.
Hide a command or subspace by starting the name with
[Hidden]. For example, this subspace and this command will not be visible in the
Lookerbot's help menu lists the available commands as well as a description of the dashboard that gets returned:
- In Looker, navigate to the dashboard.
- Click Edit and then click the Settings icon.
- In the Description field, enter the description you want to appear in the Lookerbot help menu.
- Click Save.