Skip to content

slack-samples/bolt-js-search-template

Repository files navigation

Bolt for JavaScript Search Template

⚠️ Beta Notice: This template demonstrates search functionality that is currently in beta and not yet widely available to all developers. The features shown here are being tested and may change before general availability.

This is a Slack app template for building search functionality using Bolt for Node. It demonstrates how to create custom functions for search and filtering capabilities.

It's recommended to use a developer sandbox for development and testing. Other workspaces may not have access to all these features. To get started:

  1. Join the Slack Developer Program if you haven't already
  2. Provision a sandbox workspace

Installation

Using Slack CLI

Install the latest version of the Slack CLI for your operating system:

You'll also need to log in if this is your first time using the Slack CLI.

slack login

Initializing the project

slack create bolt-js-search --template slack-samples/bolt-js-search-template
cd bolt-js-search

Running the app

slack run

Using Terminal

  1. Open https://api.slack.com/apps/new and choose "From an app manifest"
  2. Choose the workspace you want to install the application to
  3. Copy the contents of manifest.json into the text box that says *Paste your manifest code here* (within the JSON tab) and click Next
  4. Review the configuration and click Create
  5. Click Install to Workspace and Allow on the screen that follows. You'll then be redirected to the App Configuration dashboard.

Environment Variables

Before you can run the app, you'll need to store some environment variables.

  1. Copy .env.sample to .env
  2. Open your apps configuration page from this list, click OAuth & Permissions in the left hand menu, then copy the Bot User OAuth Token into your .env file under SLACK_BOT_TOKEN
  3. Click Basic Information from the left hand menu and follow the steps in the App-Level Tokens section to create an app-level token with the connections:write scope. Copy that token into your .env as SLACK_APP_TOKEN.
Install Dependencies

npm install

Run Bolt Server

npm start

Testing

Run the code linting and tests:

npm test

Format the source code:

npm run lint:fix

Project Structure

manifest.json

manifest.json is a configuration for Slack apps. With a manifest, you can create an app with a pre-defined configuration, or adjust the configuration of an existing app.

app.js

app.js is the entry point for the application and is the file you'll run to start the server. This project aims to keep this file as thin as possible, primarily using it as a way to route inbound requests.

/listeners

Every incoming request is routed to a "listener". Inside this directory, we group each listener based on the Slack Platform feature used, so /listeners/events handles incoming Events requests, /listeners/functions handles custom steps and so on.

/test

The /test directory contains the test suite for this project. It mirrors the structure of the source code, with test files corresponding to their implementation counterparts. For example, tests for files in /listeners/functions are located in /test/listeners/functions.

About

A template for implementing enterprise search in Bolt for node

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6