Skip to content

Commit 79b43e2

Browse files
Docs: Custom steps for JIRA tutorial. (#1214)
* custom steps tutorial * PR feedback
1 parent 35a4b09 commit 79b43e2

File tree

9 files changed

+174
-1
lines changed

9 files changed

+174
-1
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Custom steps for JIRA
2+
3+
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:
4+
5+
1. Create your app from an app manifest and clone a starter template
6+
2. Set up and run your local project
7+
3. Create a workflow with a custom step using Workflow Builder
8+
4. Create an issue in JIRA using your custom step
9+
10+
## Prerequisites {#prereqs}
11+
12+
Before getting started, you will need the following:
13+
14+
* 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.
15+
* a development environment with [Python 3.6](https://www.python.org/downloads/) or later.
16+
17+
**Skip to the code**
18+
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.
19+
20+
## Creating your app {#create-app}
21+
22+
1. Navigate to the [app creation page](https://api.slack.com/apps/new) and select **From a manifest**.
23+
2. Select the workspace you want to install the application in, then click **Next**.
24+
3. Copy the contents of the [`manifest.json`](https://github.com/slack-samples/bolt-python-ai-chatbot/blob/main/manifest.json) file below into the text box that says **Paste your manifest code here** (within the **JSON** tab), then click **Next**:
25+
26+
```js reference title="manifest.json"
27+
https://github.com/slack-samples/bolt-python-jira-functions/blob/main/manifest.json
28+
```
29+
30+
4. Review the configuration and click **Create**.
31+
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.
32+
33+
### Obtaining and storing your environment variables {#environment-variables}
34+
35+
Before you'll be able to successfully run the app, you'll need to obtain and set some environment variables.
36+
37+
1. Once you have installed the app to your workspace, copy the **Bot User OAuth Token** from the **Install App** page. You will store this in your environment as `SLACK_BOT_TOKEN` (we'll get to that next).
38+
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`.
39+
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.
40+
4. Run the following commands in your terminal to store your environment variables, client ID, and client secret.
41+
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**).
42+
43+
**For macOS**
44+
```bash
45+
export SLACK_BOT_TOKEN=<your-bot-token>
46+
export SLACK_APP_TOKEN=<your-app-token>
47+
export JIRA_CLIENT_ID=<client-id>
48+
export JIRA_CLIENT_SECRET=<client-secret>
49+
```
50+
51+
**For Windows**
52+
```bash
53+
set SLACK_BOT_TOKEN=<your-bot-token>
54+
set SLACK_APP_TOKEN=<your-app-token>
55+
set JIRA_CLIENT_ID=<client-id>
56+
set JIRA_CLIENT_SECRET=<client-secret>
57+
```
58+
59+
## Setting up and running your local project {#configure-project}
60+
61+
Clone the starter template onto your machine by running the following command:
62+
63+
```bash
64+
git clone https://github.com/slack-samples/bolt-python-jira-functions.git
65+
```
66+
67+
Change into the new project directory:
68+
69+
```bash
70+
cd bolt-python-jira-functions
71+
```
72+
73+
Start your Python virtual environment:
74+
75+
import Tabs from '@theme/Tabs';
76+
import TabItem from '@theme/TabItem';
77+
78+
<Tabs groupId="os">
79+
<TabItem value="macos" label="For macOS">
80+
81+
```bash
82+
python3 -m venv .venv
83+
source .venv/bin/activate
84+
```
85+
86+
</TabItem>
87+
<TabItem value="windows" label="For Windows">
88+
89+
```bash
90+
py -m venv .venv
91+
.venv\Scripts\activate
92+
```
93+
</TabItem>
94+
</Tabs>
95+
96+
Install the required dependencies:
97+
98+
```bash
99+
pip install -r requirements.txt
100+
```
101+
102+
Rename the `.example.env` file to `.env` and replace the values for each of the variables listed in the file:
103+
104+
```
105+
JIRA_BASE_URL=https://your-jira-instance.com
106+
SECRET_HEADER_KEY=Your-Header
107+
SECRET_HEADER_VALUE=abc123
108+
JIRA_CLIENT_ID=abc123
109+
JIRA_CLIENT_SECRET=abc123
110+
APP_BASE_URL=https://1234-123-123-12.ngrok-free.app
111+
APP_HOME_PAGE_URL=slack://app?team=YOUR_TEAM_ID&id=YOUR_APP_ID&tab=home
112+
```
113+
114+
You could also store the values for your `SLACK_BOT_TOKEN` and `SLACK_APP_TOKEN` here.
115+
116+
Start your local server:
117+
118+
```bash
119+
python app.py
120+
```
121+
122+
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.
123+
124+
## Setting up your workflow in Workflow Builder {#workflow}
125+
126+
1. Within your development workspace, open Workflow Builder by clicking your workspace name and then selecting **Tools** > **Workflow Builder**.
127+
2. Select **New Workflow** > **Build Workflow**.
128+
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**.
129+
130+
![Workflow details](/img/custom-steps-jira/1.png)
131+
132+
4. Select **Choose an event** under **Start the workflow...**, and then select **From a link in Slack**. Click **Continue**.
133+
134+
![Start the workflow](/img/custom-steps-jira/2.png)
135+
136+
5. Under **Then, do these things** click **Add steps** to add the custom step. Your custom step will be the function defined in the [`create_issue.py`](https://github.com/slack-samples/bolt-python-jira-functions/blob/main/listeners/functions/create_issue.py) file.
137+
138+
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**.
139+
140+
![Custom function](/img/custom-steps-jira/3.png)
141+
142+
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**.
143+
144+
![Insert variable for issue URL](/img/custom-steps-jira/4.png)
145+
146+
7. Click **Publish** to make the workflow available to your workspace.
147+
148+
## Running your app {#run}
149+
150+
1. Copy your workflow link.
151+
2. Navigate to your app's home tab and click **Connect an Account** to connect your JIRA account to the app.
152+
153+
![Connect account](/img/custom-steps-jira/5.png)
154+
155+
3. Click **Allow** on the screen that appears.
156+
157+
![Allow connection](/img/custom-steps-jira/6.png)
158+
159+
4. In any channel, post the workflow link you copied.
160+
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.
161+
162+
![JIRA issue](/img/custom-steps-jira/7.png)
163+
164+
When finished, you can click the **Disconnect Account** button in the home tab to disconnect your app from your JIRA account.
165+
166+
## Next steps {#next-steps}
167+
168+
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.
169+
170+
* To learn more about Bolt for Python, refer to the [getting started](/getting-started) documentation.
171+
* 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.
172+
* 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).

docs/sidebars.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ const sidebars = {
8383
label: 'Tutorials',
8484
items: [
8585
'tutorial/getting-started-http',
86-
'tutorial/ai-chatbot'
86+
'tutorial/ai-chatbot',
87+
`tutorial/custom-steps-for-jira`
8788
],
8889
},
8990
{ type: 'html', value: '<hr>' },
78.2 KB
Loading
165 KB
Loading
50.8 KB
Loading
55.2 KB
Loading
34.2 KB
Loading
95.8 KB
Loading
78.6 KB
Loading

0 commit comments

Comments
 (0)