Skip to content

Commit ca3a3d3

Browse files
committed
Add Gmail delivery to HN briefing agent
1 parent 0192b6e commit ca3a3d3

6 files changed

Lines changed: 234 additions & 157 deletions

File tree

always_on_agents/always_on_hn_briefing_agent/README.md

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
AgentScout is an always-on Hacker News briefing agent built with Google ADK. It scans Hacker News for high-signal stories about AI agents, MCP, coding agents, workflow automation, and LLM apps, then turns the best links into a concise engineering brief.
44

5-
The app can run as an interactive ADK agent or as a scheduled backend service. Use ADK Web to ask for a brief manually, or run the FastAPI scheduler hook so Cloud Scheduler can trigger a daily Hacker News briefing and send the rendered payload to email, Slack, Linear, Jira, or an internal digest workflow.
5+
The app can run as an interactive ADK agent or as a scheduled backend service. Use ADK Web to ask for a brief manually, or run the FastAPI scheduler hook so Cloud Scheduler can trigger a daily Hacker News briefing and send it through Gmail, Slack, Linear, Jira, or an internal digest workflow.
66

7-
![Always-on Hacker News Briefing Agent architecture](assets/agent-scout-architecture.svg)
7+
![Always-on Hacker News Briefing Agent architecture](assets/always-on-hn-briefing-agent.png)
88

99
## Features
1010

@@ -13,7 +13,8 @@ The app can run as an interactive ADK agent or as a scheduled backend service. U
1313
- **Brief generation**: Produces a clean text and HTML briefing with summaries, links, and next actions.
1414
- **Google ADK agent**: Exposes a `root_agent` so users can request briefs in ADK Web.
1515
- **Scheduler-ready backend**: Includes HTTP and Pub/Sub endpoints for Cloud Scheduler or other automation systems.
16-
- **Safe delivery flow**: Defaults to dry-run mode and only posts to a webhook when `dry_run=false`.
16+
- **Gmail and webhook delivery**: Sends briefs through Gmail API or a generic webhook when `dry_run=false`.
17+
- **Safe delivery flow**: Defaults to dry-run mode and skips delivery unless credentials are explicitly configured.
1718

1819
## How It Works
1920

@@ -22,13 +23,14 @@ The app can run as an interactive ADK agent or as a scheduled backend service. U
2223
3. It ranks the most useful stories for engineers and product builders.
2324
4. It renders a daily briefing in text and HTML.
2425
5. ADK Web, an HTTP trigger, or a Pub/Sub push endpoint returns the result.
25-
6. If delivery is enabled, the scheduler API posts the brief to `AGENTSCOUT_WEBHOOK_URL`.
26+
6. If delivery is enabled, the scheduler API sends the brief through Gmail or posts it to `AGENTSCOUT_WEBHOOK_URL`.
2627

2728
## Requirements
2829

2930
- Python 3.10+
30-
- Gemini API key for Google ADK
31-
- Optional webhook URL for scheduled delivery
31+
- Gemini API key for ADK Web
32+
- Optional Gmail OAuth credentials for direct email delivery
33+
- Optional webhook URL for Slack, Linear, Jira, GitHub Issues, SendGrid, or internal workflows
3234

3335
## Installation
3436

@@ -39,7 +41,9 @@ pip install -r requirements.txt
3941
export GOOGLE_API_KEY="your_gemini_api_key"
4042
```
4143

42-
## Run in ADK Web
44+
## Option 1: Run in ADK Web
45+
46+
Use ADK Web when you want to chat with the agent and ask for a brief manually.
4347

4448
```bash
4549
adk web .
@@ -61,37 +65,81 @@ Scout the top 3 Hacker News stories about AI agents and LLM apps.
6165
Show me the highest-signal Hacker News items about MCP, coding agents, and workflow automation.
6266
```
6367

64-
## Run the Scheduler API
68+
## Option 2: Run the Scheduler API Locally
69+
70+
Use the scheduler API when you want AgentScout to run like an always-on backend service. This is the same surface you can deploy behind Cloud Run and trigger from Cloud Scheduler.
6571

6672
Start the scheduler backend:
6773

6874
```bash
6975
uvicorn scheduler_api:app --host 0.0.0.0 --port 8000
7076
```
7177

72-
Preview a scheduled run without delivery:
78+
In another terminal, preview a scheduled run without delivery:
7379

7480
```bash
7581
curl "http://127.0.0.1:8000/agent-scout/dry-run?top_n=3&live=false"
7682
```
7783

78-
Trigger the scheduler path:
84+
Trigger the scheduler path in dry-run mode:
7985

8086
```bash
8187
curl -X POST "http://127.0.0.1:8000/agent-scout/trigger" \
8288
-H "Content-Type: application/json" \
8389
-d '{"dry_run": true, "top_n": 5, "live": false}'
8490
```
8591

86-
Enable live Hacker News scanning:
92+
Dry-run mode returns the rendered brief and delivery status, but it does not send anything.
93+
94+
Enable live Hacker News scanning for the current process:
8795

8896
```bash
8997
export AGENTSCOUT_LIVE_HN=true
9098
```
9199

92-
Enable webhook delivery:
100+
You can also override live mode per request:
93101

94102
```bash
103+
curl -X POST "http://127.0.0.1:8000/agent-scout/trigger" \
104+
-H "Content-Type: application/json" \
105+
-d '{"dry_run": true, "top_n": 5, "live": true}'
106+
```
107+
108+
## Option 3: Enable Scheduled Delivery
109+
110+
Delivery is opt-in. AgentScout will not send email or call a webhook unless the request body includes `"dry_run": false` and one delivery method is configured.
111+
112+
Delivery mode behavior:
113+
114+
- `AGENTSCOUT_DELIVERY=gmail` sends through Gmail API.
115+
- `AGENTSCOUT_DELIVERY=webhook` posts to `AGENTSCOUT_WEBHOOK_URL`.
116+
- If `AGENTSCOUT_DELIVERY` is not set, AgentScout uses Gmail when Gmail is fully configured, otherwise webhook when a webhook URL is configured.
117+
118+
### Gmail Delivery
119+
120+
Use Gmail when you want AgentScout to send the daily brief directly to an inbox. Create a Google OAuth client with Gmail API access, generate a refresh token with the `https://www.googleapis.com/auth/gmail.send` scope, then set:
121+
122+
```bash
123+
export AGENTSCOUT_DELIVERY="gmail"
124+
export AGENTSCOUT_EMAIL_TO="you@example.com"
125+
export AGENTSCOUT_EMAIL_FROM="you@example.com"
126+
export AGENTSCOUT_GMAIL_CLIENT_ID="your_google_oauth_client_id"
127+
export AGENTSCOUT_GMAIL_CLIENT_SECRET="your_google_oauth_client_secret"
128+
export AGENTSCOUT_GMAIL_REFRESH_TOKEN="your_gmail_refresh_token"
129+
130+
curl -X POST "http://127.0.0.1:8000/agent-scout/trigger" \
131+
-H "Content-Type: application/json" \
132+
-d '{"dry_run": false, "top_n": 5, "live": true}'
133+
```
134+
135+
AgentScout sends a multipart email with both plain text and HTML versions of the brief.
136+
137+
### Webhook Delivery
138+
139+
Use webhook delivery when you want to route the brief to Slack, Linear, Jira, GitHub Issues, SendGrid, or your own internal workflow.
140+
141+
```bash
142+
export AGENTSCOUT_DELIVERY="webhook"
95143
export AGENTSCOUT_WEBHOOK_URL="https://example.com/agent-brief-webhook"
96144
export AGENTSCOUT_WEBHOOK_TOKEN="optional_bearer_token"
97145

@@ -104,7 +152,7 @@ The webhook receives `subject`, `text`, `html`, `stories`, and `next_actions`.
104152

105153
## Cloud Scheduler Hook
106154

107-
Deploy the scheduler API behind Cloud Run or another HTTP service, then call one of these endpoints from Cloud Scheduler.
155+
Deploy the scheduler API behind Cloud Run or another HTTP service, configure Gmail or webhook delivery in that environment, then call one of these endpoints from Cloud Scheduler.
108156

109157
Direct HTTP trigger:
110158

@@ -122,6 +170,8 @@ Request body:
122170
}
123171
```
124172

173+
Set `dry_run` to `true` while testing the schedule. Set it to `false` only after Gmail or webhook delivery is configured.
174+
125175
Recommended weekday briefing schedule:
126176

127177
```text

always_on_agents/always_on_hn_briefing_agent/assets/agent-scout-architecture.svg

Lines changed: 0 additions & 139 deletions
This file was deleted.
1.4 MB
Loading

0 commit comments

Comments
 (0)