# thurpe/x_autoreply_bot architecture

> Architecture diagram of the GitHub repository thurpe/x_autoreply_bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thurpe/x_autoreply_bot
- Repository: https://github.com/thurpe/x_autoreply_bot

## Overview

This is a Node.js Twitter support-and-engagement bot with separate v1.1 and v2 implementations. Its main workflow polls Twitter for DMs and mentions, generates FAQ replies, tags messages by priority, responds through Twitter, and tracks processed and tagged messages in memory. Operators can inspect prioritized messages and trigger actions through management endpoints; scheduled jobs provide periodic checks and update tweets where enabled. The README documents both API versions and these product capabilities; the v1.1 source excerpt is partial, so uncertain scheduling links are omitted.

Main entry points: [`index.js`](https://github.com/thurpe/x_autoreply_bot/blob/main/index.js) (DM handling), [`twitterClientv2.js`](https://github.com/thurpe/x_autoreply_bot/blob/main/twitterClientv2.js) (v2 client), [`twitterClient.js`](https://github.com/thurpe/x_autoreply_bot/blob/main/twitterClient.js) (v1.1 client), [`index-v2.js`](https://github.com/thurpe/x_autoreply_bot/blob/main/index-v2.js) (v2 bot)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtimes"]
  node_v1app["v1.1 bot<br/>[index.js]"]
  node_v2app["v2 bot<br/>[index-v2.js]"]
end

subgraph group_handling["Message handling"]
  node_dm["DM handling<br/>[index.js]"]
  node_mentions["Mention handling<br/>[index.js]"]
  node_response["FAQ responses<br/>[index.js]"]
  node_tagging["Priority tagging<br/>[index.js]"]
  node_state[("Message tracking<br/>[index.js]")]
end

subgraph group_management["Management and scheduling"]
  node_managementapi["Management API<br/>[index.js]"]
  node_v2management["v2 management API<br/>[index-v2.js]"]
  node_priorities["Priority listing<br/>[index.js]"]
  node_scheduler["Scheduled jobs<br/>[index-v2.js]"]
  node_tweet["Tweet sending<br/>[index.js]"]
  node_v2tweet["v2 scheduled tweet<br/>[index-v2.js]"]
end

subgraph group_integration["Twitter integration"]
  node_v1client["v1.1 client<br/>[twitterClient.js]"]
  node_v2client["v2 client<br/>[twitterClientv2.js]"]
end

node_customer(("Customer"))
node_operator(("Operator"))
node_twitter{{"Twitter API"}}

node_customer -->|"sends messages"| node_twitter
node_v1app -->|"dispatches"| node_dm
node_v1app -->|"dispatches"| node_mentions
node_dm -->|"requests DMs"| node_v1client
node_mentions -->|"requests mentions"| node_v1client
node_v1client -->|"calls API"| node_twitter
node_twitter -->|"returns DMs"| node_dm
node_twitter -->|"returns mentions"| node_mentions
node_dm -->|"generates reply"| node_response
node_mentions -->|"generates reply"| node_response
node_dm -->|"tags message"| node_tagging
node_mentions -->|"tags message"| node_tagging
node_dm -->|"sends reply"| node_v1client
node_mentions -->|"posts reply"| node_v1client
node_dm -->|"tracks processing"| node_state
node_mentions -->|"tracks processing"| node_state
node_operator -->|"calls endpoints"| node_managementapi
node_managementapi -->|"requests listing"| node_priorities
node_priorities -->|"reads tags"| node_state
node_managementapi -->|"marks resolved"| node_state
node_managementapi -->|"triggers check"| node_dm
node_managementapi -->|"triggers check"| node_mentions
node_managementapi -->|"requests tweet"| node_tweet
node_tweet -->|"posts tweet"| node_v1client
node_operator -->|"calls endpoints"| node_v2management
node_v2management -->|"reads or updates"| node_state
node_v2app -->|"dispatches"| node_dm
node_v2app -->|"dispatches"| node_mentions
node_dm -->|"requests DMs"| node_v2client
node_mentions -->|"requests mentions"| node_v2client
node_v2client -->|"calls API"| node_twitter
node_twitter -->|"returns data"| node_v2client
node_v2client -->|"sends replies"| node_twitter
node_scheduler -->|"dispatches checks"| node_dm
node_scheduler -->|"dispatches checks"| node_mentions
node_scheduler -->|"dispatches tweet"| node_v2tweet
node_v2tweet -->|"posts tweet"| node_v2client
node_v2app -->|"tags messages"| node_tagging
node_v2app -->|"generates replies"| node_response
node_v2app -->|"tracks processing"| node_state

click node_v1app "https://github.com/thurpe/x_autoreply_bot/blob/main/index.js"
click node_v2app "https://github.com/thurpe/x_autoreply_bot/blob/main/index-v2.js"
click node_v1client "https://github.com/thurpe/x_autoreply_bot/blob/main/twitterClient.js"
click node_v2client "https://github.com/thurpe/x_autoreply_bot/blob/main/twitterClientv2.js"
click node_dm "https://github.com/thurpe/x_autoreply_bot/blob/main/index.js"
click node_mentions "https://github.com/thurpe/x_autoreply_bot/blob/main/index.js"
click node_response "https://github.com/thurpe/x_autoreply_bot/blob/main/index.js"
click node_tagging "https://github.com/thurpe/x_autoreply_bot/blob/main/index.js"
click node_state "https://github.com/thurpe/x_autoreply_bot/blob/main/index.js"
click node_managementapi "https://github.com/thurpe/x_autoreply_bot/blob/main/index.js"
click node_v2management "https://github.com/thurpe/x_autoreply_bot/blob/main/index-v2.js"
click node_priorities "https://github.com/thurpe/x_autoreply_bot/blob/main/index.js"
click node_scheduler "https://github.com/thurpe/x_autoreply_bot/blob/main/index-v2.js"
click node_tweet "https://github.com/thurpe/x_autoreply_bot/blob/main/index.js"
click node_v2tweet "https://github.com/thurpe/x_autoreply_bot/blob/main/index-v2.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_v1app,node_v2app toneBlue
class node_dm,node_mentions,node_response,node_tagging,node_state toneAmber
class node_managementapi,node_v2management,node_priorities,node_scheduler,node_tweet,node_v2tweet,node_twitter toneMint
class node_v1client,node_v2client toneRose
class node_customer,node_operator toneIndigo
```

## Components

### Bot runtimes

- [v1.1 bot](https://github.com/thurpe/x_autoreply_bot/blob/main/index.js): `index.js`
- [v2 bot](https://github.com/thurpe/x_autoreply_bot/blob/main/index-v2.js): `index-v2.js`

### Message handling

- [DM handling](https://github.com/thurpe/x_autoreply_bot/blob/main/index.js): `index.js`
- [Mention handling](https://github.com/thurpe/x_autoreply_bot/blob/main/index.js): `index.js`
- [FAQ responses](https://github.com/thurpe/x_autoreply_bot/blob/main/index.js): `index.js`
- [Priority tagging](https://github.com/thurpe/x_autoreply_bot/blob/main/index.js): `index.js`
- [Message tracking](https://github.com/thurpe/x_autoreply_bot/blob/main/index.js): `index.js`

### Management and scheduling

- [Management API](https://github.com/thurpe/x_autoreply_bot/blob/main/index.js): `index.js`
- [v2 management API](https://github.com/thurpe/x_autoreply_bot/blob/main/index-v2.js): `index-v2.js`
- [Priority listing](https://github.com/thurpe/x_autoreply_bot/blob/main/index.js): `index.js`
- [Scheduled jobs](https://github.com/thurpe/x_autoreply_bot/blob/main/index-v2.js): `index-v2.js`
- [Tweet sending](https://github.com/thurpe/x_autoreply_bot/blob/main/index.js): `index.js`
- [v2 scheduled tweet](https://github.com/thurpe/x_autoreply_bot/blob/main/index-v2.js): `index-v2.js`

### Twitter integration

- [v1.1 client](https://github.com/thurpe/x_autoreply_bot/blob/main/twitterClient.js): `twitterClient.js`
- [v2 client](https://github.com/thurpe/x_autoreply_bot/blob/main/twitterClientv2.js): `twitterClientv2.js`

### Other components

- **Customer**
- **Operator**
- **Twitter API**

## Connections

- Customer → Twitter API: sends messages
- v1.1 bot → DM handling: dispatches
- v1.1 bot → Mention handling: dispatches
- DM handling → v1.1 client: requests DMs
- Mention handling → v1.1 client: requests mentions
- v1.1 client → Twitter API: calls API
- Twitter API → DM handling: returns DMs
- Twitter API → Mention handling: returns mentions
- DM handling → FAQ responses: generates reply
- Mention handling → FAQ responses: generates reply
- DM handling → Priority tagging: tags message
- Mention handling → Priority tagging: tags message
- DM handling → v1.1 client: sends reply
- Mention handling → v1.1 client: posts reply
- DM handling → Message tracking: tracks processing
- Mention handling → Message tracking: tracks processing
- Operator → Management API: calls endpoints
- Management API → Priority listing: requests listing
- Priority listing → Message tracking: reads tags
- Management API → Message tracking: marks resolved
- Management API → DM handling: triggers check
- Management API → Mention handling: triggers check
- Management API → Tweet sending: requests tweet
- Tweet sending → v1.1 client: posts tweet
- Operator → v2 management API: calls endpoints
- v2 management API → Message tracking: reads or updates
- v2 bot → DM handling: dispatches
- v2 bot → Mention handling: dispatches
- DM handling → v2 client: requests DMs
- Mention handling → v2 client: requests mentions
- v2 client → Twitter API: calls API
- Twitter API → v2 client: returns data
- v2 client → Twitter API: sends replies
- Scheduled jobs → DM handling: dispatches checks
- Scheduled jobs → Mention handling: dispatches checks
- Scheduled jobs → v2 scheduled tweet: dispatches tweet
- v2 scheduled tweet → v2 client: posts tweet
- v2 bot → Priority tagging: tags messages
- v2 bot → FAQ responses: generates replies
- v2 bot → Message tracking: tracks processing
