Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.
feat(automations): rename Automations to Instagram automation with its own icon
spacesdrivea591393c6c0a
diff --git a/docs/architecture/cloudflare/WORKERS.md b/docs/architecture/cloudflare/WORKERS.mdindex 6211db0..df7476e 100644--- a/docs/architecture/cloudflare/WORKERS.md+++ b/docs/architecture/cloudflare/WORKERS.md@@ -56,7 +56,7 @@ All secrets are set via `npx wrangler secret put <NAME>`, run from `backend/`. T| `RESEND_API_KEY` | Optional | Resend API key with sending access; sends the auth emails (verification codes) || `EMAIL_FROM` | Optional | Sender of the auth emails on a domain verified in Resend, such as `Twiligent <[email protected]>` || `EMAIL_DAILY_LIMIT` | Optional | Auth emails a day across all users (each code sign-in is one) before the sign-in page pauses email codes and points to Google or a password; defaults to `100`, Resend's free daily quota |-| `INSTAGRAM_WEBHOOK_VERIFY_TOKEN` | Optional | The Verify Token typed into the Meta dashboard's Instagram webhook settings; `GET /api/webhooks/instagram` answers Meta's check only with it. Without it, and `INSTAGRAM_APP_SECRET`, no comment reaches the Worker and the Automations page says so |+| `INSTAGRAM_WEBHOOK_VERIFY_TOKEN` | Optional | The Verify Token typed into the Meta dashboard's Instagram webhook settings; `GET /api/webhooks/instagram` answers Meta's check only with it. Without it, and `INSTAGRAM_APP_SECRET`, no comment reaches the Worker and the Instagram automation page says so || `CLOUDINARY_API_KEY`, `CLOUDINARY_API_SECRET` | Optional | The Cloudinary account's API key and secret (Settings, API Keys). Only for deleting files through the Claude `delete_media` tool; without them a delete removes Twiligent's record and says the file stays on Cloudinary. Never sent to the browser || `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET` | Optional | The Google Cloud Web application OAuth client for YouTube publishing (redirect URI `<BACKEND_URL>/api/auth/youtube/callback`). With `TOKEN_ENCRYPTION_KEY` they turn YouTube publishing on; see `docs/platform-v2/YOUTUBE_INTEGRATION.md` || `TOKEN_ENCRYPTION_KEY` | Optional | At least 32 random characters (`openssl rand -base64 48`). Keys derived from it sign the MCP confirmation tokens and seal the stored Google tokens (AES-GCM). Without it the Claude tools that publish or delete refuse to run and YouTube publishing stays off. Changing it voids confirmations in flight and makes every stored Google token unreadable, so people connect YouTube again |diff --git a/docs/architecture/data-flows/AUTOMATION.md b/docs/architecture/data-flows/AUTOMATION.mdindex 8c04465..03e464d 100644--- a/docs/architecture/data-flows/AUTOMATION.md+++ b/docs/architecture/data-flows/AUTOMATION.md@@ -284,7 +284,7 @@ The batch cap of 15 comes from the Workers Free plan's 50 subrequests per invoca| Each reconcile run: expired counts, review results for both kinds (public: found, not found, failed, sent again), queue health (due, oldest due, waiting, stale, needs review, follow-ups due, public replies due, stale and checking, paused and limited accounts) | `automation reconcile` || The queue falling behind: the oldest due reply or public reply waited over 10 minutes, or jobs are held by stopped runs | one `automation queue behind: ...` warning per run, so an incident does not flood the logs || Every non-dispatch cron run and its duration | `cron run finished` |-| Accounts at their limit, cooling down, held, or without message events, and public replies cooling down or at their limit | the Instagram accounts card on the Automations page |+| Accounts at their limit, cooling down, held, or without message events, and public replies cooling down or at their limit | the Instagram accounts card on the Instagram automation page |Logs carry ids, statuses and error codes, never tokens, secrets, comment text or message text.diff --git a/docs/architecture/frontend/ROUTING.md b/docs/architecture/frontend/ROUTING.mdindex 9109ac1..b12fd22 100644--- a/docs/architecture/frontend/ROUTING.md+++ b/docs/architecture/frontend/ROUTING.md@@ -25,7 +25,7 @@ The app uses React Router 7 in `frontend/src/App.tsx`: a data router from `creat| `/reels` | redirect | Redirects to `/instagram`, keeping the query string and hash || `/publish` | `UploadContent.tsx` | Instagram publishing (sidebar and page title): publish and schedule to Instagram, plus the scheduled post queue || `/upload` | redirect | Redirects to `/publish`, keeping the query string and hash |-| `/automations` | `features/automations/Automations.tsx` | Comment-to-DM rules, account controls and reply activity; in the sidebar under Publishing |+| `/automations` | `features/automations/Automations.tsx` | Instagram automation (sidebar and page title): comment-to-DM rules, account controls and reply activity; in the sidebar under Publishing || `/automations/rules/new` | `features/automations/RuleEditorPage.tsx` | Create a rule on its own page, with a warning before leaving unsaved changes || `/automations/rules/:id` | `features/automations/RuleEditorPage.tsx` | Edit the rule with that id || `/settings` | `Settings.tsx` | User/platform settings |diff --git a/docs/workflows/RECOVERY.md b/docs/workflows/RECOVERY.mdindex 6bf80ac..9217004 100644--- a/docs/workflows/RECOVERY.md+++ b/docs/workflows/RECOVERY.md@@ -19,7 +19,7 @@ A person who reports an error can quote the request id at the end of the error m| Problem | Step | Effect ||---|---|---|| Comment replies go out wrong or too fast | `npx wrangler secret put AUTOMATION_PAUSED` with the value `true` | Every reply is held; comments are still recorded and wait. Remove the secret, or set `false`, to resume |-| One Instagram account replies badly | Pause the account on the Automations page | Only that account stops |+| One Instagram account replies badly | Pause the account on the Instagram automation page | Only that account stops || A scheduled post keeps failing | Read its reason in the scheduled posts list on the Instagram publishing page | A temporary failure is tried up to three times and a permanent one once; the post is then marked Failed with the reason and is not tried again || A secret leaked | Set a new value with `npx wrangler secret put <NAME>` and revoke the old one where it was issued (Meta, Google, Resend, Supabase) | The Worker uses the new value on its next request |diff --git a/docs/workflows/TESTING.md b/docs/workflows/TESTING.mdindex 32bdb76..855603b 100644--- a/docs/workflows/TESTING.md+++ b/docs/workflows/TESTING.md@@ -245,10 +245,10 @@ Open the app in a browser. For each changed area, test:- [ ] The anon key gets 401 permission denied on every table (including the automation tables and `audit_events`) and on the merge and automation functions: `curl -i "<SUPABASE_URL>/rest/v1/accounts?select=id" -H "apikey: <anon key>"` (repeat for `settings`, `scheduled_posts`, `tracked_posts`) and `curl -i -X POST "<SUPABASE_URL>/rest/v1/rpc/merge_account_data" -H "apikey: <anon key>" -H "Content-Type: application/json" -d '{}'`- [ ] The app still lists accounts, scheduled posts and tracked items, and the row counts in the Table Editor are unchanged-**Comment automation (if the webhook, rules, the processor or the Automations page changed):**+**Comment automation (if the webhook, rules, the processor or the Instagram automation page changed):**- [ ] `curl -i "<worker>/api/webhooks/instagram?hub.mode=subscribe&hub.verify_token=<token>&hub.challenge=123"` answers `123`; a wrong token answers 403- [ ] `curl -i -X POST -H "Content-Type: application/json" -d '{"object":"instagram","entry":[]}' <worker>/api/webhooks/instagram` without a signature answers 401 and stores nothing-- [ ] Create a rule on the Automations page, turn it on, and the account shows Receiving comments (or Turn on comment events succeeds)+- [ ] Create a rule on the Instagram automation page, turn it on, and the account shows Receiving comments (or Turn on comment events succeeds)- [ ] Test a comment on the rule editor page: a matching sample says it matches, a non-matching one says no reply, and nothing is sent- [ ] From another Instagram account, comment the keyword on a covered post: the private reply arrives within seconds, Activity shows Accepted by Instagram, and `npx wrangler tail` shows `instagram webhook stored` and `automation reply settled` with no token or comment text in any line- [ ] Comment the same keyword again on a post the rule does not cover: Activity shows No match without the wordsdiff --git a/frontend/src/features/automations/Automations.tsx b/frontend/src/features/automations/Automations.tsxindex d08898e..ff93d46 100644--- a/frontend/src/features/automations/Automations.tsx+++ b/frontend/src/features/automations/Automations.tsx@@ -1,6 +1,6 @@import { useMemo } from 'react';import { Link, useNavigate } from 'react-router-dom';-import { MessageSquareReply, Plus } from 'lucide-react';+import { BotMessageSquare, Plus } from 'lucide-react';import { Button } from '@/components/ui/button';import PageHeader from '@/components/PageHeader';import SurfaceBox from '@/components/SurfaceBox';@@ -29,7 +29,7 @@ export default function Automations() {const hasRules = Boolean(overview && overview.rules.length > 0);const header = (<PageHeader- title="Automations"+ title="Instagram automation"description="Answer comments on your posts and reels with a private reply, a public reply under the comment, or both."actions={hasRules && (<Button render={<Link to={newRulePath} />}><Plus data-icon="inline-start" />New rule</Button>@@ -44,7 +44,7 @@ export default function Automations() {<div className="flex flex-col gap-6">{header}<SurfaceBox>- <ErrorState title="Automations could not load" description={automations.loadError} onRetry={automations.load} />+ <ErrorState title="Instagram automation could not load" description={automations.loadError} onRetry={automations.load} /></SurfaceBox></div>);@@ -56,9 +56,9 @@ export default function Automations() {{header}<SurfaceBox><EmptyState- icon={<MessageSquareReply />}+ icon={<BotMessageSquare />}title="Connect an Instagram account first"- description="Automations reply from an Instagram professional account connected with Instagram sign-in."+ description="Instagram automation replies from an Instagram professional account connected with Instagram sign-in."action={<Button render={<Link to="/accounts?add=1" />}>Add account</Button>}/></SurfaceBox>diff --git a/frontend/src/features/automations/RuleEditorPage.tsx b/frontend/src/features/automations/RuleEditorPage.tsxindex 3bd5dba..d5fcb44 100644--- a/frontend/src/features/automations/RuleEditorPage.tsx+++ b/frontend/src/features/automations/RuleEditorPage.tsx@@ -300,7 +300,7 @@ export default function RuleEditorPage() {const header = (<PageHeader- back={{ to: '/automations', label: 'Automations' }}+ back={{ to: '/automations', label: 'Instagram automation' }}title={title}description="When a comment matches, Twiligent answers its author in a private message, publicly under the comment, or both."/>diff --git a/frontend/src/layout/navigation.ts b/frontend/src/layout/navigation.tsindex 1452f92..28c1b09 100644--- a/frontend/src/layout/navigation.ts+++ b/frontend/src/layout/navigation.ts@@ -1,5 +1,5 @@import {- LayoutDashboard, PlaySquare, Scissors, Clapperboard, Bookmark, Send, CloudUpload, MessageSquareReply, Users, Settings,+ LayoutDashboard, PlaySquare, Scissors, Clapperboard, Bookmark, Send, CloudUpload, BotMessageSquare, Users, Settings,} from 'lucide-react';import type { LucideIcon } from 'lucide-react';import { activeNavPath, routeTitle as titleForRoute } from './routes';@@ -35,7 +35,7 @@ export const NAV_GROUPS: NavGroup[] = [items: [{ path: '/publish', label: 'Instagram publishing', icon: Send },{ path: '/youtube-uploads', label: 'YouTube uploads', icon: CloudUpload },- { path: '/automations', label: 'Automations', icon: MessageSquareReply },+ { path: '/automations', label: 'Instagram automation', icon: BotMessageSquare },],},{diff --git a/frontend/src/layout/routes.ts b/frontend/src/layout/routes.tsindex 93f3de4..aa12e96 100644--- a/frontend/src/layout/routes.ts+++ b/frontend/src/layout/routes.ts@@ -26,8 +26,8 @@ export const DETAIL_ROUTES: DetailRoute[] = [{ prefix: '/channel/', label: 'YouTube channel', parent: { path: '/', label: 'Overview' } },{ prefix: '/instagram/', label: 'Instagram account', parent: { path: '/', label: 'Overview' } },{ prefix: '/tracked-content/category/', label: 'Category', parent: { path: '/tracked-content', label: 'Tracked content' } },- { prefix: '/automations/rules/new', label: 'New rule', parent: { path: '/automations', label: 'Automations' } },- { prefix: '/automations/rules/', label: 'Edit rule', parent: { path: '/automations', label: 'Automations' } },+ { prefix: '/automations/rules/new', label: 'New rule', parent: { path: '/automations', label: 'Instagram automation' } },+ { prefix: '/automations/rules/', label: 'Edit rule', parent: { path: '/automations', label: 'Instagram automation' } },];export const APP_NAME = 'Twiligent';diff --git a/site/content/docs/self-host/comment-automation.mdx b/site/content/docs/self-host/comment-automation.mdxindex 43a0be7..14be4b7 100644--- a/site/content/docs/self-host/comment-automation.mdx+++ b/site/content/docs/self-host/comment-automation.mdx@@ -50,12 +50,12 @@ Subscribe to the **messages** field too only if you will use followers-only rule</Step><Step title="Turn on comment events for each account">-In Twiligent, open **Automations**, create a rule and turn it on. The first rule turned on for an account asks Instagram to send that account's comments to your backend, and a followers-only rule asks for its messages as well. If the account shows **Not receiving comments**, choose **Turn on comment events**; if it shows **Follow checks off**, select the messages field in the Meta dashboard and choose **Turn on message events**. The account must be public: Instagram sends no comment events for private accounts.+In Twiligent, open **Instagram automation**, create a rule and turn it on. The first rule turned on for an account asks Instagram to send that account's comments to your backend, and a followers-only rule asks for its messages as well. If the account shows **Not receiving comments**, choose **Turn on comment events**; if it shows **Follow checks off**, select the messages field in the Meta dashboard and choose **Turn on message events**. The account must be public: Instagram sends no comment events for private accounts.</Step><Step title="Test it">-From another Instagram account, comment a rule's keyword on one of the account's posts. The private reply should arrive within a few seconds, and a public reply appear under the comment if the rule has one. To follow it, run `npx wrangler tail` in `backend/` and look for `instagram webhook stored`, `automation reply settled` and `automation public reply settled`. Meta also sends the account's own public reply back as a comment; it is recorded as the account's own and never answered. The comment and its status also appear under **Activity** on the Automations page.+From another Instagram account, comment a rule's keyword on one of the account's posts. The private reply should arrive within a few seconds, and a public reply appear under the comment if the rule has one. To follow it, run `npx wrangler tail` in `backend/` and look for `instagram webhook stored`, `automation reply settled` and `automation public reply settled`. Meta also sends the account's own public reply back as a comment; it is recorded as the account's own and never answered. The comment and its status also appear under **Activity** on the Instagram automation page.For a followers-only rule, reply to the first message from the commenting account. If that account follows yours, the reply and link arrive; if not, the reminder does. Look for `automation follow-up settled` in the log.diff --git a/site/content/docs/use/automations.mdx b/site/content/docs/use/automations.mdxindex 447a46e..e8de9ec 100644--- a/site/content/docs/use/automations.mdx+++ b/site/content/docs/use/automations.mdx@@ -1,16 +1,16 @@export const meta = { title: 'Reply to comments automatically', description: 'Answer people who comment a keyword on your Instagram posts and reels with a private message, a public reply under their comment, or both.' }-Automations answer people who comment a keyword, such as GUIDE, on one of your posts or reels, or any comment at all on the posts you choose. A rule can send them a private reply, post a public reply under their comment, or both. A typical rule sends a link in private ("Here is your guide" and the address of the guide) and thanks them in public.+Instagram automation answers people who comment a keyword, such as GUIDE, on one of your posts or reels, or any comment at all on the posts you choose. A rule can send them a private reply, post a public reply under their comment, or both. A typical rule sends a link in private ("Here is your guide" and the address of the guide) and thanks them in public.<Callout type="note" title="Before you start">-You need an Instagram Business or Creator account connected with Instagram sign-in, and the account must be public. Your administrator also turns on comment events for the server; until they do, the Automations page says comment events are not set up.+You need an Instagram Business or Creator account connected with Instagram sign-in, and the account must be public. Your administrator also turns on comment events for the server; until they do, the Instagram automation page says comment events are not set up.</Callout>## Create a rule-1. Open **Automations** in the sidebar and choose **New rule**. The rule opens on its own page.+1. Open **Instagram automation** in the sidebar and choose **New rule**. The rule opens on its own page.2. Choose the Instagram account, give the rule a name, and type its keywords, separated by commas.3. Choose how comments match. **Anywhere in the comment, as a whole word** answers "send me the guide please" for GUIDE but not "guidelines". **The whole comment, nothing else** answers only a comment that is the keyword. **Any comment, no keyword needed** answers everyone who comments.4. Choose **Every post and reel**, or **Only the posts I choose** and pick them.