|
| 1 | +# Configuration Guide |
| 2 | + |
| 3 | +I've created a `.env` file for you with the tokens you provided, but there are a few values that need to be filled in. The OpenProject API is returning "Access denied" from this environment, so you'll need to find these values directly. |
| 4 | + |
| 5 | +## Values to Find |
| 6 | + |
| 7 | +### 1. Backend Project ID |
| 8 | + |
| 9 | +**Current placeholder:** `BACKEND_PROJECT_ID` in `REPO_PROJECT_MAP` |
| 10 | + |
| 11 | +**How to find it:** |
| 12 | + |
| 13 | +**Option A - Via Web UI:** |
| 14 | +1. Go to https://op.stoatinternal.com/projects/backend |
| 15 | +2. Click on "Project settings" (gear icon) |
| 16 | +3. The project ID should be visible in the settings page |
| 17 | + |
| 18 | +**Option B - Via API (from your local machine):** |
| 19 | +```bash |
| 20 | +curl -H "Authorization: Basic $(echo -n 'apikey:74b417798ae1a1c038cf9cd3677cd1d5a44568c477f4d1b998c4d1eb03016d5f' | base64)" \ |
| 21 | + https://op.stoatinternal.com/api/v3/projects/backend | jq '.id' |
| 22 | +``` |
| 23 | + |
| 24 | +**Option C - From any work package URL:** |
| 25 | +1. Open any work package in the backend project |
| 26 | +2. Look at the API link in the page |
| 27 | +3. The project reference will be there |
| 28 | + |
| 29 | +**Expected value:** An integer like `8` or `42` |
| 30 | + |
| 31 | +**Update in .env:** |
| 32 | +```bash |
| 33 | +REPO_PROJECT_MAP=stoatchat/stoatchat:8 # Replace 8 with actual ID |
| 34 | +``` |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +### 2. Type IDs (for TYPE_MAP) |
| 39 | + |
| 40 | +**Current placeholder:** `FIND_ME` for Bug, Task, Feature |
| 41 | + |
| 42 | +**How to find them:** |
| 43 | + |
| 44 | +**Option A - Via browser console:** |
| 45 | +1. Open https://op.stoatinternal.com in your browser |
| 46 | +2. Open Developer Tools (F12) |
| 47 | +3. Go to Console tab |
| 48 | +4. Run: |
| 49 | +```javascript |
| 50 | +fetch('/api/v3/types', { |
| 51 | + headers: { |
| 52 | + 'Authorization': 'Basic ' + btoa('apikey:74b417798ae1a1c038cf9cd3677cd1d5a44568c477f4d1b998c4d1eb03016d5f') |
| 53 | + } |
| 54 | +}) |
| 55 | +.then(r => r.json()) |
| 56 | +.then(data => { |
| 57 | + data._embedded.elements.forEach(t => console.log(t.id + ': ' + t.name)); |
| 58 | +}); |
| 59 | +``` |
| 60 | + |
| 61 | +**Option B - Via API from your machine:** |
| 62 | +```bash |
| 63 | +curl -H "Authorization: Basic $(echo -n 'apikey:74b417798ae1a1c038cf9cd3677cd1d5a44568c477f4d1b998c4d1eb03016d5f' | base64)" \ |
| 64 | + https://op.stoatinternal.com/api/v3/types | jq '._embedded.elements[] | "\(.id): \(.name)"' |
| 65 | +``` |
| 66 | + |
| 67 | +**Expected output:** |
| 68 | +``` |
| 69 | +1: Task |
| 70 | +2: Bug |
| 71 | +3: Feature |
| 72 | +... |
| 73 | +``` |
| 74 | + |
| 75 | +**Update in .env:** |
| 76 | +```bash |
| 77 | +TYPE_MAP=Bug:2,Task:1,Feature:3 # Use actual IDs from your OpenProject |
| 78 | +``` |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +### 3. Custom Field ID (OP_GITHUB_ISSUE_FIELD) |
| 83 | + |
| 84 | +**Current placeholder:** `FIND_ME` |
| 85 | + |
| 86 | +**How to find it:** |
| 87 | + |
| 88 | +**Option A - Via Administration:** |
| 89 | +1. Go to OpenProject → Administration (top right menu) |
| 90 | +2. Click "Custom fields" in the left sidebar |
| 91 | +3. Find the "GitHub Issue" field (should be an Integer field) |
| 92 | +4. Note the ID shown in the list |
| 93 | + |
| 94 | +**Option B - Via browser console on a work package:** |
| 95 | +1. Open any work package: https://op.stoatinternal.com/work_packages/1 |
| 96 | +2. Open Developer Tools → Console |
| 97 | +3. Run: |
| 98 | +```javascript |
| 99 | +fetch('/api/v3/work_packages/1', { |
| 100 | + headers: { |
| 101 | + 'Authorization': 'Basic ' + btoa('apikey:74b417798ae1a1c038cf9cd3677cd1d5a44568c477f4d1b998c4d1eb03016d5f') |
| 102 | + } |
| 103 | +}) |
| 104 | +.then(r => r.json()) |
| 105 | +.then(data => { |
| 106 | + Object.keys(data).filter(k => k.startsWith('customField')).forEach(k => { |
| 107 | + console.log(k + ': ' + data[k]); |
| 108 | + }); |
| 109 | +}); |
| 110 | +``` |
| 111 | + |
| 112 | +**Expected output:** |
| 113 | +``` |
| 114 | +customField42: null |
| 115 | +customField43: 123 |
| 116 | +... |
| 117 | +``` |
| 118 | + |
| 119 | +Look for the field that's used for GitHub issue numbers (it will be the "GitHub Issue" field you created). |
| 120 | + |
| 121 | +**Update in .env:** |
| 122 | +```bash |
| 123 | +OP_GITHUB_ISSUE_FIELD=customField42 # Use actual field ID |
| 124 | +``` |
| 125 | + |
| 126 | +--- |
| 127 | + |
| 128 | +### 4. User IDs (for ASSIGNEE_MAP) - Optional |
| 129 | + |
| 130 | +**How to find them:** |
| 131 | + |
| 132 | +**Option A - Via Administration:** |
| 133 | +1. Go to OpenProject → Administration → Users |
| 134 | +2. Click on a user |
| 135 | +3. The ID is in the URL: `/users/42` means user ID is 42 |
| 136 | + |
| 137 | +**Option B - Via API:** |
| 138 | +```bash |
| 139 | +curl -H "Authorization: Basic $(echo -n 'apikey:74b417798ae1a1c038cf9cd3677cd1d5a44568c477f4d1b998c4d1eb03016d5f' | base64)" \ |
| 140 | + https://op.stoatinternal.com/api/v3/users | jq '._embedded.elements[] | "\(.id): \(.login) (\(.name))"' |
| 141 | +``` |
| 142 | + |
| 143 | +**Update in .env:** |
| 144 | +```bash |
| 145 | +ASSIGNEE_MAP=insertish:42,other_github_user:43 |
| 146 | +``` |
| 147 | + |
| 148 | +--- |
| 149 | + |
| 150 | +### 5. SECRET_TOKEN |
| 151 | + |
| 152 | +**Current value:** `CHANGE_ME_GENERATE_RANDOM_TOKEN` |
| 153 | + |
| 154 | +Generate a secure random token: |
| 155 | + |
| 156 | +```bash |
| 157 | +# On Linux/Mac: |
| 158 | +openssl rand -hex 32 |
| 159 | + |
| 160 | +# Or use this online: https://www.random.org/strings/ |
| 161 | +``` |
| 162 | + |
| 163 | +**Update in .env:** |
| 164 | +```bash |
| 165 | +SECRET_TOKEN=your_generated_random_token_here |
| 166 | +``` |
| 167 | + |
| 168 | +--- |
| 169 | + |
| 170 | +## After Configuration |
| 171 | + |
| 172 | +Once you've filled in all the values, your `.env` should look like: |
| 173 | + |
| 174 | +```bash |
| 175 | +GH_TOKEN=github_pat_... |
| 176 | +OP_TOKEN=74b417798... |
| 177 | +OP_URL=https://op.stoatinternal.com |
| 178 | +SECRET_TOKEN=a1b2c3d4e5f6... |
| 179 | +REPO_PROJECT_MAP=stoatchat/stoatchat:8 |
| 180 | +ASSIGNEE_MAP=insertish:42 |
| 181 | +TYPE_MAP=Bug:2,Task:1,Feature:3 |
| 182 | +OP_GITHUB_ISSUE_FIELD=customField42 |
| 183 | +``` |
| 184 | + |
| 185 | +Then you can start the service: |
| 186 | + |
| 187 | +```bash |
| 188 | +deno task start |
| 189 | +``` |
| 190 | + |
| 191 | +## Webhook URLs |
| 192 | + |
| 193 | +After the service is running, configure webhooks: |
| 194 | + |
| 195 | +**GitHub webhook:** |
| 196 | +``` |
| 197 | +URL: https://your-domain.com/webhook/YOUR_SECRET_TOKEN/github |
| 198 | +Content type: application/json |
| 199 | +Events: Issues |
| 200 | +``` |
| 201 | + |
| 202 | +**OpenProject webhook:** |
| 203 | +``` |
| 204 | +URL: https://your-domain.com/webhook/YOUR_SECRET_TOKEN/openproject |
| 205 | +Events: Work package created, Work package updated |
| 206 | +``` |
| 207 | + |
| 208 | +## Troubleshooting |
| 209 | + |
| 210 | +If you get "Access denied" from OpenProject API even from your local machine: |
| 211 | +1. Check that the API token has the correct permissions in OpenProject |
| 212 | +2. Make sure you're using an admin account or have project access |
| 213 | +3. Try regenerating the API token in your OpenProject user settings |
0 commit comments