Skip to content

Commit be123e4

Browse files
committed
edited golang-slackbot readme
1 parent fc38e14 commit be123e4

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

samples/golang-slackbot/README.md

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ This is a simple slackbot that takes a request and posts the message from the bo
66

77
## Prerequisites
88

9-
Install the Defang CLI by following the instructions in the [Defang CLI documentation](https://docs.defang.io/docs/getting-started).
9+
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
10+
2. (Optional) If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) authenticate with your cloud provider account
11+
3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/)
12+
1013

1114
### Slack API Token
1215

@@ -19,28 +22,55 @@ Make sure to:
1922
- Copy the Bot User OAuth Access Token
2023
- Invite your bot to the channel you want it to post to using the `@botname` command in the channel (this will allow you to invite it)
2124

22-
## Configure
2325

24-
Before deploying the Slackbot, you need to set up some config values. These config values are environment variables that the Slackbot needs to function correctly. The values are:
26+
## Development
27+
28+
To run the application locally, you can use the following command:
2529

26-
- `SLACK_TOKEN`: This is the token you copied previously for the Slack API.
27-
- `SLACK_CHANNEL_ID`: This is the ID of the Slack channel where the bot will post messages.
30+
```bash
31+
docker compose up --build
32+
```
2833

29-
You can set these config parameters using the `defang config set` command. Here's how:
34+
## Configuration
3035

31-
```sh
32-
defang config set --name SLACK_TOKEN --value your_slack_token
33-
defang config set --name SLACK_CHANNEL_ID --value your_slack_channel_id
36+
For this sample, you will need to provide the following [configuration](https://docs.defang.io/docs/concepts/configuration):
37+
38+
> Note that if you are using the 1-click deploy option, you can set these values as secrets in your GitHub repository and the action will automatically deploy them for you.
39+
40+
### `SLACK_TOKEN`
41+
This is the token you've copied previously for the Slack API.
42+
```bash
43+
defang config set SLACK_TOKEN
44+
```
45+
46+
### `SLACK_CHANNEL_ID`
47+
This is the ID of the Slack channel where the bot will post messages.
48+
```bash
49+
defang config set SLACK_CHANNEL_ID
3450
```
3551

36-
## Deploy
52+
## Deployment
3753

38-
If you have environment variables configured for your [own cloud account](https://docs.defang.io/docs/concepts/defang-byoc), this will deploy the application to your cloud account, otherwise it will deploy to the Defang playground.
54+
> [!NOTE]
55+
> Download [Defang CLI](https://github.com/DefangLabs/defang)
3956
40-
```sh
57+
### Defang Playground
58+
59+
Deploy your application to the Defang Playground by opening up your terminal and typing:
60+
```bash
4161
defang compose up
4262
```
4363

64+
### BYOC (AWS)
65+
66+
If you want to deploy to your own cloud account, you can use Defang BYOC:
67+
68+
1. [Authenticate your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html), and check that you have properly set your environment variables like `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`.
69+
2. Run in a terminal that has access to your AWS environment variables:
70+
```bash
71+
defang --provider=aws compose up
72+
73+
4474
## Usage
4575

4676
Once the Slackbot is deployed, you can send a POST request to the `/` endpoint with a JSON body containing the message you want to post to the Slack channel. Here's an example:

0 commit comments

Comments
 (0)