-
Notifications
You must be signed in to change notification settings - Fork 250
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
Add next-gen future documentation #761
Changes from 1 commit
ab7cf70
9eb3ec7
9ddbc2f
995b72f
7a77d70
cafdf9c
aab5657
2b8d053
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ coverage.xml | |
.python-version | ||
pip | ||
.mypy_cache/ | ||
.ruby-version | ||
|
||
# JetBrains PyCharm settings | ||
.idea/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
source 'https://rubygems.org' | ||
gem 'github-pages', group: :jekyll_plugins | ||
gem 'dotenv' | ||
gem 'webrick' | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: Slack developer beta | ||
lang: en | ||
slug: concepts | ||
order: 0 | ||
layout: future | ||
permalink: /future/concepts | ||
--- | ||
# Slack developer beta concepts <span class="label-beta">BETA</span> | ||
hello-ashleyintech marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<div class="section-content"> | ||
This page contains all the concepts that are necessary to allow you to use the next-gen Slack features in Python. | ||
<p class="alert alert_info"><ts-icon class="ts_icon_info_circle"></ts-icon>Our next-generation platform is currently in beta. <a href="https://api.slack.com/future/survey" target="_blank">Your feedback is most welcome</a> - all feedback will help shape the future platform experience!</p> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
|
||
title: Deploy your app | ||
lang: en | ||
slug: deploy-your-app | ||
order: 6 | ||
layout: tutorial | ||
permalink: /tutorial/deploy-your-app | ||
--- | ||
# Deploy your app <span class="label-beta">BETA</span> | ||
|
||
<div class="section-content"> | ||
Instructions for deploying your next-generation Bolt Python application to third-party infrastructure are coming soon! Stay tuned. | ||
|
||
<p class="alert alert_info"><ts-icon class="ts_icon_info_circle"></ts-icon>Our next-generation platform is currently in beta. <a href="https://api.slack.com/future/survey" target="_blank">Your feedback is most welcome</a> - all feedback will help shape the future platform experience!</p> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
--- | ||
title: Getting started | ||
order: 1 | ||
slug: getting-started-future | ||
lang: en | ||
layout: tutorial | ||
permalink: /tutorial/getting-started-future | ||
--- | ||
|
||
## Getting started <span class="label-beta">BETA</span> | ||
|
||
<div class="section-content"> | ||
This guide will cover how to get started with your next-gen platform using Bolt for Python, by setting up the Slack CLI and installing the required dependencies. | ||
|
||
Find out about the next-generation platform on Slack's <a href="https://api.slack.com/future/intro" target="_blank">official introduction page.</a> | ||
</div> | ||
|
||
--- | ||
|
||
### Limitations | ||
|
||
Bolt for Python supports app development using next-gen platform features like Functions, Workflows and tools such as the Slack CLI alongside all current generally available Slack Platform features. | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### We do not yet support | ||
|
||
- Deployment to secure and managed Slack infrastructure. | ||
- Datastores API <a href="https://api.slack.com/future/datastores" target="_blank">Datastores</a> functionality. | ||
|
||
> If you'd like to deploy your app with Slack infrastructure, consider building your next-generation application with the Deno Slack API. You can get started with that <a href="https://api.slack.com/future/get-started" target="_blank">here</a>. | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
--- | ||
|
||
### Setting up {#setting-up} | ||
|
||
#### Slack CLI {#setting-up-cli} | ||
|
||
To build a next-generation app with Bolt for Python, you'll need to get the Slack CLI. | ||
|
||
Install the Slack CLI by following this <a href="https://api.slack.com/future/quickstart" target="_blank">Quickstart</a>. Since we won't be using Deno to build our next-generation app, you can skip any instructions related to installing Deno or creating an app using a Deno template. Once you've logged into the CLI using `slack login` and verified your login using `slack auth list`, you can proceed with the instructions in this guide. | ||
|
||
#### Dependencies {#setting-up-dependencies} | ||
|
||
Once the CLI is set up, make sure your machine has the most recent version of <a href="https://www.python.org/" target="_blank">Python</a> installed. You can install Python through a package manager (such as <a href="https://brew.sh/" target="_blank">Homebrew</a> for Mac) or directly from the <a href="https://www.python.org/downloads/" target="_blank">website</a>. | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
--- | ||
|
||
### Create a new app {#create-app} | ||
|
||
Before you start developing with Bolt, you'll want to create a Slack app. | ||
|
||
To create the app, you'll run the following command: | ||
|
||
```bash | ||
slack create my-app -t slack-samples/bolt-python-starter-template -b future | ||
``` | ||
|
||
This command creates an app through the CLI by cloning a specified template. In this case, the template is the <a href="https://github.com/slack-samples/bolt-python-starter-template/tree/future" target="_blank">Bolt for Python Starter Template</a> on the `future` branch. This starter template includes a "Hello World" example that demonstrates how to use <a href="/bolt-python/future/concepts#built-in-functions" target="_blank">built-in</a> and <a href="/bolt-python/future/concepts#functions" target="_blank">custom</a> Functions, <a href="https://api.slack.com/future/triggers" target="_blank">Triggers</a> and <a href="/bolt-python/future/concepts#manifest-workflows" target="_blank">Workflows</a>. | ||
|
||
Once the app is successfully created, you should see a message like this: | ||
|
||
```text | ||
✨ my-app successfully created | ||
|
||
🧭 Explore your project's README.md for documentation and code samples, and at any time run slack help to display a list of available commands | ||
|
||
🧑🚀 Follow the steps below to try out your new project | ||
|
||
1️⃣ Change into your project directory with: cd my-app | ||
|
||
2️⃣ Develop locally and see changes in real-time with: slack run | ||
|
||
3️⃣ When you're ready to deploy for production use: slack deploy | ||
|
||
🔔 If you leave the workspace, you won’t be able to manage any apps you’ve deployed to it. Apps you deploy will belong to the workspace even if you leave the workspace | ||
``` | ||
|
||
--- | ||
|
||
### Set up your trigger {#setup-trigger} | ||
|
||
As mentioned, this app comes with preexisting functionality - it uses Functions, Workflows and a Trigger set up to kick things off. Let's run a command to initialize that Trigger via the CLI. | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
First, make sure you're in the project directory in your command line: `cd my-app` | ||
|
||
Then, run the following command to create a Trigger: | ||
|
||
```bash | ||
slack triggers create --trigger-def "triggers/sample-trigger.json" | ||
``` | ||
|
||
The above command will create a trigger for the selected workspace. Make sure to select the workspace you want and that it is appended by `(dev)`. This will create a dev instance of your app. Once the trigger is successfully created, you should see an output like this: | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```bash | ||
⚡ Trigger created | ||
Trigger ID: [ID] | ||
Trigger Type: shortcut | ||
Trigger Name: Sample Trigger | ||
URL: https://slack.com/shortcuts/[ID]/[Some ID] | ||
``` | ||
|
||
The provided URL will be what you use to run your Trigger. Copy this URL and save it somewhere; you'll need it for later. | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
--- | ||
|
||
### Run your app {#run-your-app} | ||
|
||
Now that your app and Trigger are successfully created, let's try running it! | ||
|
||
```bash | ||
# install the required project dependencies | ||
pip install -r requirements.txt | ||
|
||
# start a local development server | ||
slack run | ||
``` | ||
|
||
Executing `pip install -r requirements.txt` installs all the project requirements to your machine. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may want to link to any existing documentation we have around setting up a virtual env, as that is the recommended way of working in Python projects. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I've been thinking about doing this in our documentation, currently this is how we do it in the rest of our docs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's chalk it up as a separate issue so we don't forget, and if/when we get to it we can update all the documentation (new platform or otherwise) to link to it where it makes sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created issue #777 to keep track of this |
||
|
||
Executing `slack run` starts a local development server, syncing changes to your workspace's development version of your app. | ||
|
||
You'll be prompted to select a workspace to install the app to—select the development instance of your workspace (you'll know it's the development version because the name has the string `(dev)` appended). | ||
|
||
> 💡 If you don't see the workspace you'd like to use in the list, you can `CTRL + C` out of the `slack run` command and run `slack auth login`. This will allow you to authenticate in your desired workspace to have it show up in the list for `slack run`. | ||
|
||
Once the app is successfully ran, you'll see output in your Terminal to indicate it's running, similar to what you would see with any other Bolt for Python app. You can search for the `⚡️ Bolt app is running! ⚡️` message to make sure that your app has successfully started up. | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Trigger your app's workflow {#trigger-workflow} | ||
|
||
With your app running, access your workspace and paste the URL from the Trigger you created in the [previous step](/bolt-python/tutorial/getting-started-future#setup-trigger) into a message in a public channel. | ||
|
||
> 💡 App Triggers are automatically saved as a channel bookmark under "Workflows" for easy access. | ||
|
||
Send the message and click the "Run" button that appears. A modal will appear prompting you to enter information to greet someone in your Slack workspace. Fill out the requested information. | ||
|
||
![Hello World modal](https://slack.dev/bolt-js/assets/hello-world-modal.png "Hello World modal") | ||
|
||
Then, submit the form. In the specified channel submitted in the form, you should receive a message from the app tagging the submitted user. The message will also contain a randomly generated greeting and the message you wrote in the form. | ||
|
||
The full app flow can be seen here: | ||
![Hello World app](https://slack.dev/bolt-js/assets/hello-world-demo.gif "Hello World app") | ||
|
||
--- | ||
|
||
### Next steps {#next-steps} | ||
|
||
Now we have a working instance of a next-generation app in your workspace and you've seen it in action! You can explore on your own and dive into the code yourself <a href="https://github.com/slack-samples/bolt-python-starter-template/tree/future" target="_blank">here</a> or continue your learning journey by diving into [App Manifests](/bolt-python/future/concepts#manifests) or looking into adding more [Functions](/bolt-python/future/concepts#functions), [Workflows](/bolt-python/future/concepts#manifest-workflows), and [Triggers](#setup-trigger) to your app! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
--- | ||
title: Listening & responding to functions | ||
lang: en | ||
slug: functions | ||
order: 5 | ||
layout: future | ||
--- | ||
|
||
<div class="section-content"> | ||
|
||
Your app can use the `function()` method to listen to incoming function requests. The method requires a function `callback_id` of type `str`. This `callback_id` must also be defined in your [Function](/bolt-python/future/concepts#manifest-functions) definition. Functions must eventually be completed with the `complete()` function to inform Slack that your app has processed the function request. `complete()` requires **one of two** keyword arguments: `outputs` or `error`. There are two ways to complete a Function with `complete()`: | ||
|
||
* `outputs` of type `dict` completes your function **successfully** and provide a dictionary containing the outputs of your function as defined in the app's manifest. | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* `error` of type `str` completes your function **unsuccessfully** and provides a message containing information regarding why your function was not successful. | ||
|
||
</div> | ||
|
||
<div> | ||
<span class="annotation">Refer to <a href="https://slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html" target="_blank">the module document</a> to learn the available listener arguments.</span> | ||
```python | ||
# The sample function simply outputs an input | ||
@app.function("sample_function") | ||
def sample_func(event, complete: Complete): | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
try: | ||
message = event["inputs"]["message"] | ||
complete( | ||
outputs={ | ||
"updatedMsg": f":wave: You submitted the following message: \n\n>{message}" | ||
} | ||
) | ||
except Exception as e: | ||
complete(error="Cannot submit the message") | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
raise e | ||
``` | ||
</div> | ||
|
||
<details class="secondary-wrapper"> | ||
<summary markdown="0"> | ||
<h4 class="secondary-header">Function Interactivity</h4> | ||
</summary> | ||
|
||
<div class="secondary-content"> | ||
|
||
The `function()` method returns a `SlackFunction` decorator object. This object can be used by your app to set up interactive listeners such as [actions](/bolt-python/concepts#action-respond) and [views](/bolt-python/concepts#view_submissions). These listeners listen to events created during the handling of your `function` event. Additionally, they will only be called when a user interacts with a block element that has the following attributes: | ||
|
||
* It was created during the handling of a `function` event. | ||
* The `action_id` matches the interactive listeners `action_id`. | ||
|
||
These listeners behave similarly to the ones assigned directly to your app. the notable difference is that `complete()` must be called once your function is completed. | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
</div> | ||
|
||
```python | ||
# Your listener will be called when your function "sample_function" is triggered from a workflow | ||
# When triggered a message containing a button with an action_id "approve_button" is posted | ||
@app.function("sample_function") | ||
def sample_func(event, complete: Complete): | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
try: | ||
client.chat_postMessage( | ||
channel="a-channel-id", | ||
text="A new button appears", | ||
blocks=[ | ||
{ | ||
"type": "actions", | ||
"block_id": "approve-button", | ||
"elements": [ | ||
{ | ||
"type": "button", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "Click", | ||
}, | ||
"action_id": "sample_action", | ||
"style": "primary", | ||
}, | ||
], | ||
}, | ||
], | ||
) | ||
except Exception as e: | ||
complete(error="Cannot post message") | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
raise e | ||
|
||
# Your listener will be called when a block element | ||
# - Created by your "sample_func" | ||
# - With the action_id "sample_action" | ||
# is triggered | ||
@sample_func.action("sample_action") | ||
def update_message(ack, body, client, complete): | ||
try: | ||
ack() | ||
if "container" in body and "message_ts" in body["container"]: | ||
client.reactions_add( | ||
name="white_check_mark", | ||
channel=body["channel"]["id"], | ||
timestamp=body["container"]["message_ts"], | ||
) | ||
complete() | ||
except Exception as e: | ||
logger.error(e) | ||
complete(error="Cannot react to message") | ||
WilliamBergamin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
raise e | ||
``` | ||
|
||
</details> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be required when new versions of ruby are running Jekyll