-
Notifications
You must be signed in to change notification settings - Fork 277
Docs: Custom steps for JIRA tutorial. #1214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| # Custom steps for JIRA | ||
|
|
||
| In this tutorial, you'll learn how to configure custom steps for use with JIRA. Here's what we'll do with this sample app: | ||
|
|
||
| 1. Create your app from an app manifest and clone a starter template | ||
| 2. Set up and run your local project | ||
| 3. Create a workflow using Workflow Builder with custom steps | ||
| 4. Create an issue in JIRA using your custom step | ||
|
|
||
| ## Prerequisites {#prereqs} | ||
|
|
||
| Before getting started, you will need the following: | ||
|
|
||
| * a development workspace where you have permissions to install apps. If you don’t have a workspace, go ahead and set that up now—you can [go here](https://slack.com/get-started#create) to create one, or you can join the [Developer Program](https://api.slack.com/developer-program) and provision a sandbox with access to all Slack features for free. | ||
| * a development environment with [Python 3.6](https://www.python.org/downloads/) or later. | ||
|
|
||
| **Skip to the code** | ||
| If you'd rather skip the tutorial and just head straight to the code, you can use our [Bolt for Python JIRA functions sample](https://github.com/slack-samples/bolt-python-jira-functions) as a template. | ||
|
|
||
| ## Creating your app {#create-app} | ||
|
|
||
| 1. Navigate to the [app creation page](https://api.slack.com/apps/new) and select **From a manifest**. | ||
| 2. Select the workspace you want to install the application in, then click **Next**. | ||
| 3. Copy the contents of the [`manifest.json`](https://github.com/slack-samples/bolt-python-ai-chatbot/blob/main/manifest.json) file into the text box that says **Paste your manifest code here** (within the **JSON** tab) and click **Next**. | ||
technically-tracy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 4. Review the configuration and click **Create**. | ||
| 5. You're now in your app configuration's **Basic Information** page. Click **Install App**, then **Install to _your-workspace-name_**, then **Allow** on the screen that follows. | ||
|
|
||
| ### Obtaining and storing your environment variables {#environment-variables} | ||
|
|
||
| Before you'll be able to successfully run the app, you'll need to obtain and set some environment variables. | ||
|
|
||
| 1. On the **Install App** page, copy your **Bot User OAuth Token**. You will store this in your environment as `SLACK_BOT_TOKEN` (we'll get to that next). | ||
technically-tracy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 2. Navigate to **Basic Information** and in the **App-Level Tokens** section , click **Generate Token and Scopes**. Add the [`connections:write`](https://api.slack.com/scopes/connections:write) scope, name the token, and click **Generate**. (For more details, refer to [understanding OAuth scopes for bots](https://api.slack.com/tutorials/tracks/understanding-oauth-scopes-bot)). Copy this token. You will store this in your environment as `SLACK_APP_TOKEN`. | ||
| 3. Follow [these instructions](https://confluence.atlassian.com/adminjiraserver0909/configure-an-incoming-link-1251415519.html) to create an external app link and to generate its redirect URL (the base of which will be stored as your APP_BASE_URL variable below), client ID, and client secret. | ||
| 4. Run the following commands in your terminal to store your environment variables, client ID, and client secret. | ||
| 5. You'll also need to know your team ID (found by opening your Slack instance in a web browser and copying the value within the link that starts with the letter **T**) and your app ID (found under **Basic Information**). | ||
|
|
||
| **For macOS** | ||
| ```bash | ||
| export SLACK_BOT_TOKEN=<your-bot-token> | ||
| export SLACK_APP_TOKEN=<your-app-token> | ||
| export JIRA_CLIENT_ID=<client-id> | ||
| export JIRA_CLIENT_SECRET=<client-secret> | ||
| ``` | ||
|
|
||
| **For Windows** | ||
| ```bash | ||
| set SLACK_BOT_TOKEN=<your-bot-token> | ||
| set SLACK_APP_TOKEN=<your-app-token> | ||
| set JIRA_CLIENT_ID=<client-id> | ||
| set JIRA_CLIENT_SECRET=<client-secret> | ||
| ``` | ||
|
|
||
| ## Setting up and running your local project {#configure-project} | ||
|
|
||
| Clone the starter template onto your machine by running the following command: | ||
|
|
||
| ```bash | ||
| git clone https://github.com/slack-samples/bolt-python-jira-functions.git | ||
| ``` | ||
|
|
||
| Change into the new project directory: | ||
|
|
||
| ```bash | ||
| cd bolt-python-jira-functions | ||
| ``` | ||
|
|
||
| Start your Python virtual environment: | ||
|
|
||
technically-tracy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| **For macOS** | ||
| ```bash | ||
| python3 -m venv .venv | ||
| source .venv/bin/activate | ||
| ``` | ||
|
|
||
technically-tracy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| **For Windows** | ||
| ```bash | ||
| py -m venv .venv | ||
| .venv\Scripts\activate | ||
| ``` | ||
|
|
||
technically-tracy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Install the required dependencies: | ||
|
|
||
| ```bash | ||
| pip install -r requirements.txt | ||
| ``` | ||
|
|
||
| Rename the `.example.env` file to `.env` and replace the values for each of the variables listed in the file: | ||
technically-tracy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ``` | ||
| JIRA_BASE_URL=https://your-jira-instance.com | ||
| SECRET_HEADER_KEY=Your-Header | ||
| SECRET_HEADER_VALUE=abc123 | ||
| JIRA_CLIENT_ID=abc123 | ||
| JIRA_CLIENT_SECRET=abc123 | ||
| APP_BASE_URL=https://1234-123-123-12.ngrok-free.app | ||
| APP_HOME_PAGE_URL=slack://app?team=YOUR_TEAM_ID&id=YOUR_APP_ID&tab=home | ||
| ``` | ||
|
|
||
| Start your local server: | ||
|
|
||
| ```bash | ||
| python app.py | ||
| ``` | ||
|
|
||
| If your app is up and running, you'll see a message noting that the app is starting to receive messages from a new connection. | ||
|
|
||
| ## Setting up your workflow in Workflow Builder {#workflow} | ||
|
|
||
| 1. Within your development workspace, open Workflow Builder by clicking your workspace name and then selecting **Tools** > **Workflow Builder**. | ||
| 2. Select **New Workflow** > **Build Workflow**. | ||
| 3. Click **Untitled Workflow** at the top of the pane to rename your workflow. We'll call it **Create Issue**. For the description, enter _Creates a new issue_, then click **Save**. | ||
|
|
||
|  | ||
|
|
||
| 4. Select **Choose an event** under **Start the workflow...**, and then select **From a link in Slack**. Click **Continue**. | ||
|
|
||
|  | ||
|
|
||
| 5. Under **Then, do these things** click **Add steps** to add the custom step. Scroll down to the bottom of the list on the right-hand pane and select **Custom**, then **BoltPy Jira Functions** > **Create an issue**. Enter the project details, issue type (optional), summary (optional), and description (optional). Click **Save**. | ||
technically-tracy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|  | ||
|
|
||
| 6. Add another step and select **Messages** > **Send a message to a channel**. Select **Channel where the workflow was used** from the drop-down list and then select **Insert a variable** and **Issue url**. Click **Save**. | ||
|
|
||
|  | ||
|
|
||
| 7. Click **Publish** to make the workflow available to your workspace. | ||
|
|
||
| ## Running your app {#run} | ||
|
|
||
| 1. Copy your workflow link. | ||
| 2. Navigate to your app's home tab and click **Connect an Account** to connect your JIRA account to the app. | ||
|
|
||
|  | ||
|
|
||
| 3. Click **Allow** on the screen that appears. | ||
|
|
||
|  | ||
|
|
||
| 4. In any channel, post the workflow link you copied. | ||
| 5. Click **Start Workflow** and observe as the link to a new JIRA ticket is posted in the channel. Click the link to be directed to the newly-created issue within your JIRA project. | ||
|
|
||
|  | ||
|
|
||
| When finished, you can click the **Disconnect Account** button in the home tab to disconnect your app from your JIRA account. | ||
|
|
||
| ## Next steps {#next-steps} | ||
|
|
||
| Congratulations! You've successfully customized your workspace with custom steps in Workflow Builder. Check out these links to take the next steps in your journey. | ||
|
|
||
| * To learn more about Bolt for Python, refer to the [getting started](../getting-started) documentation. | ||
technically-tracy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * For more details about creating workflow steps using the Bolt SDK, refer to the [workflow steps for Bolt](https://api.slack.com/automation/functions/custom-bolt) guide. | ||
| * For information about custom steps dynamic options, refer to [custom steps dynamic options in Workflow Builder](https://api.slack.com/automation/runonslack/custom-steps-dynamic-options). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.