Skip to content

Commit 76ae035

Browse files
committed
Modify README & add_users.sh to reflect the revamped bot
1 parent 57e0568 commit 76ae035

File tree

3 files changed

+52
-41
lines changed

3 files changed

+52
-41
lines changed

README.md

+49-36
Original file line numberDiff line numberDiff line change
@@ -5,95 +5,108 @@
55
This sample Bot shows how to use the Mattermost [Go driver](https://github.com/mattermost/mattermost-server/blob/master/model/client4.go) to interact with a Mattermost server, listen to events and respond to messages. Documentation for the Go driver can be found [here](https://pkg.go.dev/github.com/mattermost/mattermost-server/v6/model).
66

77
Highlights of APIs used in this sample:
8-
- Log in to the Mattermost server
9-
- Create a channel
10-
- Modify user attributes
11-
- Connect and listen to WebSocket events for real-time responses to messages
12-
- Post a message to a channel
8+
9+
- Log in to the Mattermost server
10+
- Create a channel
11+
- Modify user attributes
12+
- Connect and listen to WebSocket events for real-time responses to messages
13+
- Post a message to a channel
1314

1415
This Bot Sample was tested with Mattermost server version 7.5.2.
1516

1617
## Setup Server Environment
1718

1819
### Via Docker And Docker-Compose
19-
1 - Ensure [Docker](https://www.docker.com/get-started) and [Docker-Compose](https://docs.docker.com/compose/install/) are installed for your system
2020

21-
2 - Run `./add_users.sh`. The login information for the Mattermost client will be printed
21+
1 - Ensure [Docker](https://www.docker.com/get-started) and [Docker-Compose](https://docs.docker.com/compose/install/) are installed on your system.
22+
23+
2 - Run `docker-compose up -d --build` and the mattermost client will be built and will expose the port `8065` to your system's localhost.
2224

23-
3 - Run `docker-compose up -d --build` and the mattermost client will be built and will expose the port `8065` to your system's localhost
25+
3 - Run `./add_users.sh`. The login information for the Mattermost client will be printed.
2426

25-
4 - Get a bot token by logging into your mattermost instance, copy `example.env` to `.env` and fill in the credentials. Alternatively, just provide your credentials as environment variables.
27+
4 - Log into your mattermost instance using these credentials and create a bot account following [these](https://developers.mattermost.com/integrate/reference/bot-accounts/) instructions.
28+
29+
5 - Copy `example.env` to `.env` and fill in the bot token (obtained from the previous step), team name, etc. Alternatively, just provide your credentials as environment variables.
2630

2731
5 - Start the Bot.
2832

2933
```
3034
make run
3135
```
32-
You can verify the Bot is running when
33-
- `Server detected and is running version X.Y.Z` appears on the command line.
34-
- `Mattermost Bot Sample has started running` is posted in the `Debugging For Sample Bot` channel.
36+
37+
You can verify the Bot is running when
38+
39+
- `Logged in to mattermost` appears on the command line.
40+
- `Hi! I am a bot.` is posted in your specified channel.
3541

3642
See "Test the Bot" for testing instructions
43+
3744
### Via Direct System Install/Setup
38-
1 - [Install](http://docs.mattermost.com/install/requirements.html) or [upgrade](https://docs.mattermost.com/administration/upgrade.html) to Mattermost server version 3.10+, and verify that the Mattermost server is running on [http://localhost:8065](http://localhost:8065).
45+
46+
1 - [Install](http://docs.mattermost.com/install/requirements.html) or [upgrade](https://docs.mattermost.com/administration/upgrade.html) to Mattermost server version 3.10+, and verify that the Mattermost server is running on [http://localhost:8065](http://localhost:8065).
3947

4048
On the commands below, if you are running Mattermost server version 5.0 or later, use `./bin/mmctl`. If you are running version 4.10 or earlier, use `./bin/platform`.
4149

4250
Learn more about the `mmctl` CLI tool in the [Mattermost documentation](https://docs.mattermost.com/administration/mmctl-cli-tool.html).
4351

44-
2 - Create a team for the Bot to run. If you have an existing team, you may skip this step and replace `team_name` with your existing team in subsequent steps.
52+
2 - Create a team for the Bot to run. If you have an existing team, you may skip this step and replace `botsample` with your existing team in subsequent steps.
53+
4554
```
4655
./bin/mmctl team create --name botsample --display_name "Sample Bot playground" --email "[email protected]"
4756
```
48-
3 - Create the user account the Bot will run as.
49-
```
50-
./bin/mmctl user create --email="[email protected]" --password="Password1!" --username="samplebot"
51-
```
52-
4 - Create a second user, `bill`, which we will use to log in and interact with the Bot.
57+
58+
3 - Create a user, `bill`, which we will use to log in and interact with the Bot.
59+
5360
```
5461
./bin/mmctl user create --email="[email protected]" --password="Password1!" --username="bill"
5562
```
56-
5 - (Optional) Give `bill` `system_admin` permissions.
63+
64+
4 - (Optional) Give `bill` `system_admin` permissions.
65+
5766
```
5867
./bin/mmctl roles system_admin bill
5968
```
60-
6 - Add users to the team
61-
```
62-
./bin/mmctl team add botsample samplebot bill
63-
```
64-
7 - Verify the e-mail address
65-
```
66-
./bin/mmctl user verify samplebot
67-
```
68-
8 - Log in to [http://localhost:8065](http://localhost:8065) as `bill` and verify the account was created successfully. Then, navigate to the `botsample` team you created in step 2 to interact with the Bot.
69+
70+
5 - Log in to [http://localhost:8065](http://localhost:8065) as `bill` and verify the account was created successfully.
71+
72+
6 - Create a bot account following [these](https://developers.mattermost.com/integrate/reference/bot-accounts/) instructions.
73+
74+
7 - Copy `example.env` to `.env` and fill in the bot token (obtained from the previous step), team name, etc. Alternatively, just provide your credentials as environment variables.
6975

7076
## Setup Bot Development Environment
7177

7278
1 - Follow the [Developer Machine Setup](https://docs.mattermost.com/developer/dev-setup.html) instructions to setup the bot development environment.
7379

7480
2 - Clone the GitHub repository to run the sample.
81+
7582
```
7683
git clone https://github.com/mattermost/mattermost-bot-sample-golang.git
7784
cd mattermost-bot-sample-golang
7885
```
79-
3 - Get a bot token by logging into your mattermost instance, copy `example.env` to `.env` and fill in the credentials.
8086

81-
4 - Start the Bot.
87+
3 - Log into your mattermost instance using these credentials and create a bot account following [these](https://developers.mattermost.com/integrate/reference/bot-accounts/) instructions.
88+
89+
4 - Copy `example.env` to `.env` and fill in the bot token (obtained from the previous step), team name, etc. Alternatively, just provide your credentials as environment variables.
90+
91+
5 - Run with
92+
8293
```
8394
make run
8495
```
85-
You can verify the Bot is running when
86-
- `Logged in to mattermost` appears on the command line.
87-
- `Hi! I am a bot.` is posted in the your specified channel.
96+
97+
You can verify the Bot is running when
98+
99+
- `Logged in to mattermost` appears on the command line.
100+
- `Hi! I am a bot.` is posted in your specified channel.
88101

89102
## Test the Bot
90103

91104
1 - Log in to the Mattermost server as `[email protected]` and `Password1!`.
92105

93-
2 - Join the your specified channel.
106+
2 - Join your specified channel.
94107

95108
3 - Post a message in the channel such as `hello?` to see if the Bot responds. You should see a response if the Bot is running.
96109

97110
## Stop the Bot
98111

99-
1 - In the terminal window, press `CTRL+C` to stop the bot. You should see `Mattermost Bot Sample has stopped running` posted in the `Debugging For Sample Bot` channel.
112+
1 - In the terminal window, press `CTRL+C` to stop the bot.

add_users.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ USER_PASS="Password1!"
33
USER_NAME="bill"
44
docker exec test_mm bash -c 'until mmctl --local system status 2> /dev/null; do echo "waiting for server to become available"; sleep 5; done'
55
docker exec test_mm mmctl --local team create --name botsample display_name "Sample Bot playground" --email "[email protected]"
6-
docker exec test_mm mmctl --local user create --email="[email protected]" --password="Password1!" --username="samplebot"
76
docker exec test_mm mmctl --local user create --email="${USER_EMAIL}" --password="${USER_PASS}" --username="${USER_NAME}"
87
docker exec test_mm mmctl --local roles system_admin bill
9-
docker exec test_mm mmctl --local team users add botsample samplebot bill
10-
docker exec test_mm mmctl --local user verify samplebot
8+
docker exec test_mm mmctl --local team users add botsample bill
119

1210
echo "Default user credentials"
1311
echo "Email: ${USER_EMAIL} - Password: ${USER_PASS}"

example.env

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
MM_TEAM="test-team"
1+
MM_TEAM="botsample"
22
MM_TOKEN="XXXXXXXXXXXXXXX"
33
MM_CHANNEL="town-square"
44
MM_SERVER="http://localhost:8065"
5-
MM_USERNAME="yourbotuser"
5+
MM_USERNAME="samplebot"

0 commit comments

Comments
 (0)