Skip to content
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

Consolidate packages and migrate installation to demo app #57

Merged
merged 20 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include LICENSE
include README.md
recursive-include response/ui/static *
recursive-include response/ui/templates *
140 changes: 2 additions & 138 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,145 +19,9 @@ If you're interested in how we use this tool at Monzo, there's an overview in [t

---

# Quick Start
# Try it out

The following steps explain how to create a Slack app, run Response locally, and configure everything to develop and test locally.

Broadly speaking, this sets things up as below:
<p align="center">
<img width="600px" src="./docs/response.svg">
</p>

## 1. Create a Slack App

- Navigate to [https://api.slack.com/apps](https://api.slack.com/apps) and click `Create New App`.
- Give it a name, e.g. 'Response', and select the relevant workspace.

- In the OAuth and Permissions page, scroll down to scopes.

- Add the following scopes:
- `channels:history`
- `channels:read`
- `channels:write`
- `chat:write:bot`
- `chat:write:user`
- `users:read`

- At the top of the page, the `Install App to Workspace` button is now available. Click it!

## 2. Configure Response

Response is configured using environment variables in a `.env` file. Create your own:
```
$ cp env.example .env
```
and update the variables in it:

### OAuth Access Token (`SLACK_TOKEN`)

Response needs an OAuth access token to use the Slack API.

- Copy the token that starts `xoxp-...` from the OAuth & Permissions section of your Slack App and use it to set the `SLACK_TOKEN` variable.

**Note:** Since some of the APIs commands we use require a _user_ token, we only need the token starting with `xoxp-...`. If/when Slack allow these actions to be controlled by Bots, we can use the _bot_ token, starting `xoxb-...`.

### Signing Secret (`SIGNING_SECRET`)

Response uses the Slack signing secret to restrict access to public endpoints.

- Copy the Signing secret from the Basic Information page and use it to set the `SIGNING SECRET` variable.

### Incident Channel (`INCIDENT_CHANNEL_NAME`)

When an incident is declared, a 'headline' post is sent to a central channel.

- The default channel is `incidents` - change `INCIDENT_CHANNEL_NAME` if you want them to be sent somewhere else (note: do not include the #).

### Bot Name (`INCIDENT_BOT_NAME`)

We want to invite the Bot to all Incident Channels, so need to know its ID.

- The default bot name is `incident` - change the `INCIDENT_BOT_NAME` if your app uses something different.

### Database encrypted field key(`ENCRYPTED_FIELD_KEY`)

Used to encrypt potentially sensitive values stored in the database for workflows.

- This can be any value but keep it secure and don't lose it. You will be unable to decrypt values from the database without it.

## 3. Run Response

From the root of the Response directory run:

```
docker-compose up
```

This starts the following containers:

- response: the main Response app
- postgres: the DB used by the app to store incident data
- cron: a container running cron, configured to hit an endpoint in Response every minute
- ngrok: ngrok in a container, providing a public URL pointed at Response.

Ngrok establishes a new, random, URL any time it starts. You'll need this to complete the Slack app setup, so look for an entry like this and make note of the https://abc123.ngrok.io address - this is your public URL.

```
ngrok | The ngrok tunnel is active
ngrok | https://6bb315c8.ngrok.io ---> response:8000
```

If everything has started successfully, you should see logs resembling the following:

```
response | Django version 2.1.7, using settings 'response.settings.dev'
response | Starting development server at http://0.0.0.0:8000/
response | Quit the server with CONTROL-C.
```

## 4. Complete the Slack App Setup

### Slash Command

- In the Slash commands page click `Create New Command`.

- Enter the following info:
- Command: `/incident`
- Request URL: `https://<public-url>/slack/slash_command`
- Short Description: `Trigger an incident`
- Usage Hint: `What's the problem?`

### Event Subscriptions

In the Event Subscriptions page we need to configure the following:

- Toggle `Enable Events` to On
- In the Request URL enter: `https://<public-url>/slack/event`
- You need to have the server running and available as Slack sends a challenge to this address and expects a specific response.

- Under the Subscribe to Bot Events section, add the following:
- `app_mention`
- `pin_added`
- `pin_removed`
- `message.channels`

### Configure interactive components

- In the Interactive Components page, enable and set the URL to `https://<public-url>/slack/action`.

### Bot Users

- In the Bot Users page, configure the Display Name and Default Username to `incident`.
- Toggle 'Always Show My Bot as Online' to On.


## 5. Test it's working!

In Slack, start an incident with `/incident Something's happened`. You should see a post in your incidents channel!

- Visit the incident doc by clicking the Doc link.
- Create a comms channel by clicking the button.
- In the comms channel check out the `@incident` commands. You can find the ones available by entering `@incident help`.
Follow the instructions in [demo/README](demo/README.md) to set up an example Django app that uses Response that you can run locally!

---

Expand Down
5 changes: 0 additions & 5 deletions core/apps.py

This file was deleted.

29 changes: 0 additions & 29 deletions core/migrations/0001_initial.py

This file was deleted.

28 changes: 0 additions & 28 deletions core/migrations/0002_auto_20190507_2049.py

This file was deleted.

26 changes: 0 additions & 26 deletions core/migrations/0003_incidentextension.py

This file was deleted.

29 changes: 0 additions & 29 deletions core/migrations/0004_create_ExternalUser.py

This file was deleted.

69 changes: 0 additions & 69 deletions core/migrations/0005_alter_use_ExternalUser.py

This file was deleted.

File renamed without changes.
File renamed without changes.
Loading