Skip to content

Commit e0d3869

Browse files
committed
Added anchor browser example project
1 parent 12bef0a commit e0d3869

File tree

3 files changed

+126
-0
lines changed

3 files changed

+126
-0
lines changed

docs/docs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@
336336
{
337337
"group": "Example projects",
338338
"pages": [
339+
"guides/example-projects/anchor-browser-web-scraper",
339340
"guides/example-projects/batch-llm-evaluator",
340341
"guides/example-projects/claude-thinking-chatbot",
341342
"guides/example-projects/human-in-the-loop-workflow",
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
title: "Automated website monitoring with Anchor Browser"
3+
sidebarTitle: "Anchor Browser web scraper"
4+
description: "Automated web monitoring using Trigger.dev's task scheduling and Anchor Browser's AI-powered browser automation."
5+
---
6+
7+
import WebScrapingWarning from "/snippets/web-scraping-warning.mdx";
8+
9+
<WebScrapingWarning />
10+
11+
## Overview
12+
13+
This example demonstrates automated web monitoring using Trigger.dev's task scheduling and Anchor Browser's AI-powered browser automation tools.
14+
15+
The task runs daily at 5pm ET to find the cheapest Broadway tickets available for same-day shows.
16+
17+
**How it works:**
18+
19+
- Trigger.dev schedules and executes the monitoring task
20+
- Anchor Browser spins up a remote browser session with an AI agent
21+
- The AI agent uses computer vision and natural language processing to analyze the TDF website
22+
- AI agent returns the lowest-priced show with specific details: name, price, and showtime
23+
24+
## Tech stack
25+
26+
- **[Node.js](https://nodejs.org)** runtime environment (version 16 or higher)
27+
- **[Trigger.dev](https://trigger.dev)** for task scheduling and task orchestration
28+
- **[Anchor Browser](https://anchorbrowser.io/)** for AI-powered browser automation
29+
- **[Playwright](https://playwright.dev/)** for browser automation libraries (handled via external dependencies)
30+
31+
## GitHub repo
32+
33+
<Card
34+
title="View the Anchor Browser web scraper repo"
35+
icon="GitHub"
36+
href="https://github.com/triggerdotdev/examples/tree/main/anchor-browser-web-scraper"
37+
>
38+
Click here to view the full code for this project in our examples repository on GitHub. You can
39+
fork it and use it as a starting point for your own project.
40+
</Card>
41+
42+
## Relevant code
43+
44+
### Broadway ticket monitor task
45+
46+
This task runs daily at 5pm ET, in [src/trigger/broadway-monitor.ts](https://github.com/triggerdotdev/examples/tree/main/anchor-browser-web-scraper/src/trigger/broadway-monitor.ts):
47+
48+
```ts
49+
import { schedules } from "@trigger.dev/sdk";
50+
import Anchorbrowser from "anchorbrowser";
51+
52+
export const broadwayMonitor = schedules.task({
53+
id: "broadway-ticket-monitor",
54+
cron: "0 21 * * *",
55+
run: async (payload, { ctx }) => {
56+
const client = new Anchorbrowser({
57+
apiKey: process.env.ANCHOR_BROWSER_API_KEY!,
58+
});
59+
60+
let session;
61+
try {
62+
// Create explicit session to get live view URL
63+
session = await client.sessions.create();
64+
console.log(`Session ID: ${session.data.id}`);
65+
console.log(`Live View URL: https://live.anchorbrowser.io?sessionId=${session.data.id}`);
66+
67+
const response = await client.tools.performWebTask({
68+
sessionId: session.data.id,
69+
url: "https://www.tdf.org/discount-ticket-programs/tkts-by-tdf/tkts-live/",
70+
prompt: `Look for the "Broadway Shows" section on this page. Find the show with the absolute lowest starting price available right now and return the show name, current lowest price, and show time. Be very specific about the current price you see. Format as: Show: [name], Price: [exact current price], Time: [time]`,
71+
});
72+
73+
console.log("Raw response:", response);
74+
75+
const result = response.data.result?.result || response.data.result || response.data;
76+
77+
if (result && typeof result === "string" && result.includes("Show:")) {
78+
console.log(`🎭 Best Broadway Deal Found!`);
79+
console.log(result);
80+
81+
return {
82+
success: true,
83+
bestDeal: result,
84+
liveViewUrl: `https://live.anchorbrowser.io?sessionId=${session.data.id}`,
85+
};
86+
} else {
87+
console.log("No Broadway deals found today");
88+
return { success: true, message: "No deals found" };
89+
}
90+
} finally {
91+
if (session?.data?.id) {
92+
try {
93+
await client.sessions.delete(session.data.id);
94+
} catch (cleanupError) {
95+
console.warn("Failed to cleanup session:", cleanupError);
96+
}
97+
}
98+
}
99+
},
100+
});
101+
```
102+
103+
### Build configuration
104+
105+
Since Anchor Browser uses browser automation libraries (Playwright) under the hood, we need to configure Trigger.dev to handle these dependencies properly by excluding them from the build bundle in [trigger.config.ts](https://github.com/triggerdotdev/examples/tree/main/anchor-browser-web-scraper/trigger.config.ts):
106+
107+
```ts
108+
import { defineConfig } from "@trigger.dev/sdk";
109+
110+
export default defineConfig({
111+
project: "proj_your_project_id_here", // Get from Trigger.dev dashboard
112+
maxDuration: 3600, // 1 hour - plenty of time for web automation
113+
dirs: ["./src/trigger"],
114+
build: {
115+
external: ["playwright-core", "playwright", "chromium-bidi"],
116+
},
117+
});
118+
```
119+
120+
## Learn more
121+
122+
- View the [Anchor Browser docs](https://anchorbrowser.io/docs) to learn more about Anchor Browser's AI-powered browser automation tools.
123+
- Check out the source code for the [Anchor Browser web scraper repo](https://github.com/triggerdotdev/examples/tree/main/anchor-browser-web-scraper) on GitHub.
124+
- Browser our [example projects](/guides/introduction) to see how you can use Trigger.dev with other services.

docs/guides/introduction.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Example projects are full projects with example repos you can fork and use. Thes
4545

4646
| Example project | Description | Framework | GitHub |
4747
| :-------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------- | :-------- | :------------------------------------------------------------------------------------------------------------- |
48+
| [Anchor Browser web scraper](/guides/example-projects/anchor-browser-web-scraper) | Monitor a website and find the cheapest tickets for a show. || [View the repo](https://github.com/triggerdotdev/examples/tree/main/anchor-browser-web-scraper) |
4849
| [Batch LLM Evaluator](/guides/example-projects/batch-llm-evaluator) | Evaluate multiple LLM models and stream the results to the frontend. | Next.js | [View the repo](https://github.com/triggerdotdev/examples/tree/main/batch-llm-evaluator) |
4950
| [Claude thinking chatbot](/guides/example-projects/claude-thinking-chatbot) | Use Vercel's AI SDK and Anthropic's Claude 3.7 model to create a thinking chatbot. | Next.js | [View the repo](https://github.com/triggerdotdev/examples/tree/main/claude-thinking-chatbot) |
5051
| [Human-in-the-loop workflow](/guides/example-projects/human-in-the-loop-workflow) | Create audio summaries of newspaper articles using a human-in-the-loop workflow built with ReactFlow and Trigger.dev waitpoint tokens. | Next.js | [View the repo](https://github.com/triggerdotdev/examples/tree/main/article-summary-workflow) |

0 commit comments

Comments
 (0)