Skip to content

A sample slack bot that implements a view submission as a slack function

License

Notifications You must be signed in to change notification settings

WilliamBergamin/bolt-python-view-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bolt Python View Function

This is a generic Bolt for Python app used to build out a workflow to implement view submissions.

Setup

Before getting started, make sure you have a development workspace where you have permissions to install apps. If you don’t have one set up, go ahead and create one. Also, please note that the workspace requires any of the Slack paid plans.

Install the Slack CLI

To use this sample, you first need to install and configure the Slack CLI. Step-by-step instructions can be found in our Quickstart Guide.

Clone the Sample App

Start by cloning this repository:

# Clone this project onto your machine
$ git clone https://github.com/WilliamBergamin/bolt-python-view-function.git

# Change into this project directory
$ cd bolt-python-view-function

# Setup your python virtual environment
$ python3 -m venv .venv
$ source .venv/bin/activate

# Install the project dependencies
$ pip install -r requirements.txt

Linting

# Run flake8 from root directory for linting
flake8 *.py && flake8 listeners/

# Run black from root directory for code formatting
black .

Create a Link Trigger

Triggers are what cause Workflows to run. These Triggers can be invoked by a user, or automatically as a response to an event within Slack.

A Link Trigger is a type of Trigger that generates a Shortcut URL which, when posted in a channel or added as a bookmark, becomes a link. When clicked, the Link Trigger will run the associated Workflow.

Link Triggers are unique to each installed version of your app. This means that Shortcut URLs will be different across each workspace, as well as between locally run. When creating a Trigger, you must select the Workspace that you'd like to create the Trigger in. Each Workspace has a development version (denoted by (dev)), as well as a deployed version.

To create a Link Trigger for the "Request Time Off" Workflow, run the following command:

slack trigger create --trigger-def manifest/triggers/sample_view_trigger.json

After selecting a Workspace, the output provided will include the Link Trigger Shortcut URL. Copy and paste this URL into a channel as a message, or add it as a bookmark in a channel of the Workspace you selected.

Note: this link won't run the Workflow until the app is either running locally or deployed! Read on to learn how to run your app locally and eventually deploy it to Slack hosting.

Running Your Project Locally

While building your app, you can see your changes propagated to your workspace in real-time with slack run. In both the CLI and in Slack, you'll know an app is the development version if the name has the string (dev) appended.

# Run app locally
$ slack run

⚡️ Bolt app is running! ⚡️

Once running, click the previously created Shortcut URL associated with the (dev) version of your app. This should start a Workflow that opens a form used to collect data around your view request!

To stop running locally, press <CTRL> + C to end the process.

About

A sample slack bot that implements a view submission as a slack function

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages