Skip to content

Commit 1542b09

Browse files
committed
docs: add ai provider token instructions
1 parent 88ddc7c commit 1542b09

File tree

1 file changed

+46
-9
lines changed

1 file changed

+46
-9
lines changed

docs/content/tutorial/ai-chatbot.md

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,66 @@ If you'd rather skip the tutorial and just head straight to the code, you can us
2525
2. Select the workspace you want to install the application in.
2626
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**.
2727
4. Review the configuration and click **Create**.
28-
5. You're now in your app configuration's **Basic Information** page. Navigate to the **Install App** link in the left nav and click **Install to Workspace*, then **Allow** on the screen that follows.
28+
5. You're now in your app configuration's **Basic Information** page. Navigate to the **Install App** link in the left nav and click **Install to Workspace**, then **Allow** on the screen that follows.
2929

3030
### Obtaining and storing your environment variables {#environment-variables}
3131

3232
Before you'll be able to successfully run the app, you'll need to first obtain and set some environment variables.
3333

34+
#### Slack tokens {#slack-tokens}
35+
36+
From your app's page on [app settings](https://api.slack.com/apps) collect an app and bot token:
37+
3438
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).
3539
2. Navigate to **Basic Information** and in the **App-Level Tokens** section , click **Generate Token and Scopes**. Add the [`connections:write`](https://docs.slack.dev/reference/scopes/connections.write) scope, name the token, and click **Generate**. (For more details, refer to [understanding OAuth scopes for bots](https://docs.slack.dev/authentication/tokens#bot)). Copy this token. You will store this in your environment as `SLACK_APP_TOKEN`.
3640

37-
To store your tokens and environment variables, run the following commands in the terminal. Replace the placeholder values with your bot and app tokens collected above, as well as the key or keys for the AI provider or providers you want to use:
41+
To store your tokens and environment variables, run the following commands in the terminal. Replace the placeholder values with your bot and app tokens collected above:
3842

3943
**For macOS**
44+
4045
```bash
4146
export SLACK_BOT_TOKEN=<your-bot-token>
4247
export SLACK_APP_TOKEN=<your-app-token>
43-
export OPENAI_API_KEY=<your-api-key>
44-
export ANTHROPIC_API_KEY=<your-api-key>
4548
```
4649

4750
**For Windows**
51+
4852
```bash
4953
set SLACK_BOT_TOKEN=<your-bot-token>
5054
set SLACK_APP_TOKEN=<your-app-token>
51-
set OPENAI_API_KEY=<your-api-key>
52-
set ANTHROPIC_API_KEY=<your-api-key>
55+
```
56+
57+
#### Provider tokens {#provider-tokens}
58+
59+
Models from different AI providers are available if the corresponding environment variable is added as shown in the sections below.
60+
61+
##### Anthropic {#anthropic}
62+
63+
To interact with Anthropic models, navigate to your Anthropic account dashboard to [create an API key](https://console.anthropic.com/settings/keys), then export the key as follows:
64+
65+
```zsh
66+
export ANTHROPIC_API_KEY=<your-api-key>
67+
```
68+
69+
##### Google Cloud Vertex AI {#google-cloud-vertex-ai}
70+
71+
To use Google Cloud Vertex AI, [follow this quick start](https://cloud.google.com/vertex-ai/generative-ai/docs/start/quickstarts/quickstart-multimodal#expandable-1) to create a project for sending requests to the Gemini API, then gather [Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc) with the strategy to match your development environment.
72+
73+
Once your project and credentials are configured, export environment variables to select from Gemini models:
74+
75+
```zsh
76+
export VERTEX_AI_PROJECT_ID=<your-project-id>
77+
export VERTEX_AI_LOCATION=<location-to-deploy-model>
78+
```
79+
80+
The project location can be located under the **Region** on the [Vertex AI](https://console.cloud.google.com/vertex-ai) dashboard, as well as more details about available Gemini models.
81+
82+
##### OpenAI {#openai}
83+
84+
Unlock the OpenAI models from your OpenAI account dashboard by clicking [create a new secret key](https://platform.openai.com/api-keys), then export the key like so:
85+
86+
```zsh
87+
export OPENAI_API_KEY=<your-api-key>
5388
```
5489

5590
## Setting up and running your local project {#configure-project}
@@ -69,12 +104,14 @@ cd bolt-python-ai-chatbot
69104
Start your Python virtual environment:
70105

71106
**For macOS**
107+
72108
```bash
73109
python3 -m venv .venv
74110
source .venv/bin/activate
75111
```
76112

77113
**For Windows**
114+
78115
```bash
79116
py -m venv .venv
80117
.venv\Scripts\activate
@@ -123,7 +160,7 @@ Under **Then, do these things**, click **Add steps** and complete the following:
123160

124161
![Send a message](/img/tutorials/ai-chatbot/3.png)
125162

126-
We'll add two more steps under the **Then, do these things** section.
163+
We'll add two more steps under the **Then, do these things** section.
127164

128165
First, scroll to the bottom of the list of steps and choose **Custom**, then choose **Bolty** and **Bolty Custom Function**. In the **Channel** drop-down menu, select **Channel that the user joined**. Click **Save**.
129166

@@ -142,7 +179,7 @@ When finished, click **Finish Up**, then click **Publish** to make the workflow
142179

143180
### Summarizing recent conversations {#summarize}
144181

145-
In order for Bolty to provide summaries of recent conversation in a channel, Bolty _must_ be a member of that channel.
182+
In order for Bolty to provide summaries of recent conversation in a channel, Bolty _must_ be a member of that channel.
146183

147184
1. Invite Bolty to a channel that you are able to leave and rejoin (for example, not the **#general** channel or a private channel someone else created) by mentioning the app in the channel — i.e., tagging **@Bolty** in the channel and sending your message.
148185
2. Slackbot will prompt you to either invite Bolty to the channel, or do nothing. Click **Invite Them**. Now when new users join the channel, the workflow you just created will be kicked off.
@@ -189,7 +226,7 @@ def handle_summary_function_callback(
189226

190227
To ask Bolty a question, you can chat with Bolty in any channel the app is in. Use the `\ask-bolty` slash command to provide a prompt for Bolty to answer. Note that Bolty is currently not supported in threads.
191228

192-
You can also navigate to **Bolty** in your **Apps** list and select the **Messages** tab to chat with Bolty directly.
229+
You can also navigate to **Bolty** in your **Apps** list and select the **Messages** tab to chat with Bolty directly.
193230

194231
![Ask Bolty](/img/tutorials/ai-chatbot/8.png)
195232

0 commit comments

Comments
 (0)