Skip to content

Commit

Permalink
Add readme / Set latest tag / Add e2e password support
Browse files Browse the repository at this point in the history
  • Loading branch information
sakowicz committed Jun 9, 2024
1 parent 120e528 commit 8267a99
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
context: .
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8
push: true
tags: sakowicz/actual-ai:${{ github.ref }}
tags: sakowicz/actual-ai:${{ github.ref }},sakowicz/actual-ai:latest
41 changes: 41 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# actual-ai

This is a project allowing you to categorize uncategorized transaction for [Actual Budget](https://actualbudget.org/) using OpenAI.

### Usage

Sample `docker-compose.yml` file:

```yaml
services:
actual_server:
image: docker.io/actualbudget/actual-server:latest
ports:
- '5006:5006'
volumes:
- ./actual-data:/data
restart: unless-stopped

actual-ai:
image: docker.io/sakowicz/actual-ai:latest
restart: unless-stopped
volumes:
- ./actual-ai-cache:/tmp/actual-ai/
environment:
- OPENAI_API_KEY=your_openai_api_key
- ACTUAL_SERVER_URL=http://actual_server:5006
- ACTUAL_PASSWORD=your_actual_password
- ACTUAL_BUDGET_ID=your_actual_budget_id # This is the ID from Settings → Show advanced settings → Sync ID
- CLASSIFICATION_SCHEDULE_CRON="0 */4 * * *" # How often to run classification.
- CLASSIFY_ON_STARTUP=true # Whether to classify transactions on startup (don't wait for cron schedule)
- SYNC_ACCOUNTS_BEFORE_CLASSIFY=true # Whether to sync accounts before classification
# - ACTUAL_E2E_PASSWORD= # optional. required if you have E2E encryption
```

### Notes from the author

I'm not a Node developer.
I have no experience with AI or GitHub actions.
I've created this script to help categorise hundreds of transactions in my Actual Budget and decided to publish it.

Feel free to suggest changes or open a MR.
14 changes: 11 additions & 3 deletions src/actual-api.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
const actualApi = require('@actual-app/api');
const fs = require('fs');

const dataDir = '/tmp/budgets';
const { serverURL, password, budgetId } = require('./config');
const dataDir = '/tmp/actual-ai/';
const {
serverURL, password, budgetId, e2ePassword,
} = require('./config');

async function initializeApi() {
if (!fs.existsSync(dataDir)) {
fs.mkdirSync(dataDir);
}
await actualApi.init({ dataDir, serverURL, password });
await actualApi.downloadBudget(budgetId);
if (e2ePassword) {
await actualApi.downloadBudget(budgetId, {
password: e2ePassword,
});
} else {
await actualApi.downloadBudget(budgetId);
}
}

async function shutdownApi() {
Expand Down
1 change: 1 addition & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
serverURL: process.env.ACTUAL_SERVER_URL,
password: process.env.ACTUAL_PASSWORD,
budgetId: process.env.ACTUAL_BUDGET_ID,
e2ePassword: process.env.ACTUAL_E2E_PASSWORD,
cronSchedule: process.env.CLASSIFICATION_SCHEDULE_CRON,
classifyOnStartup: process.env.CLASSIFY_ON_STARTUP === 'true',
syncAccountsBeforeClassify: process.env.SYNC_ACCOUNTS_BEFORE_CLASSIFY === 'true',
Expand Down

0 comments on commit 8267a99

Please sign in to comment.