# /tenders

> Scrape, analyze, and report on public tenders from briefing-nadmetanja.hr for ACME Agency.


# Tender Scraper & Analyzer — ACME Agency

You are managing the Briefing.ba tender pipeline for ACME Agency, a Croatian/Bosnian paid ads agency.

## What this skill does

Scrape public tenders (nadmetanja) from briefing-nadmetanja.hr, score them for marketing relevance, and output a structured report + Google Doc.

## Available actions

- `/tenders` or `/tenders scrape` — Full run: scrape, analyze, update Google Doc
- `/tenders analyze` — Re-analyze existing scraped data (no login needed)
- `/tenders doc` — Regenerate the Google Doc from existing analysis

## How to run

### Step 1: Scrape tenders
Run the Playwright scraper:
```bash
cd c:/Users/faris/agency-os && node ACME Agency/tenders/scraper.mjs
```
This logs into briefing-nadmetanja.hr (credentials in `.env`: BRIEFING_USERNAME, BRIEFING_PASSWORD), sets filters to:
- **Type:** nadmetanja (active tenders only)
- **"Moje objave" checked** (subscription filter — keeps only relevant categories)
- **Date range:** last 3 months
Then opens each tender detail page and saves everything to `ACME Agency/tenders/tenders_detailed.json`.

### Step 2: Analyze & score
Run the analyzer:
```bash
cd c:/Users/faris/agency-os && node ACME Agency/tenders/analyze.mjs
```
This re-scores tenders based on **title-only keywords** (NOT detail page text, which has site template noise like "facebook", "web" links in the footer).

**Scoring system:**
- **TOP PRIORITY (15+):** digital marketing, ads, campaigns, media buying, social media, advertising, branding
- **WORTH ACME AgencyWING (8-14):** PR, design, content, media monitoring, TV/radio
- **MAYBE RELEVANT (3-7):** events, conferences, portals
- **NOT RELEVANT (0-2):** everything else

Output: `ACME Agency/tenders/tenders_analyzed.json`

### Step 3: Update Google Doc
The Google Doc lives in Drive at: `1.Klijenti / ACME Agency / Tenderi/`

To regenerate:
```bash
DOC_ID="<id>"
```

1. Clear the doc (get endIndex, deleteContentRange)
2. Generate `doc_content.txt` from `tenders_analyzed.json`
3. Write to doc in chunks using: `gws docs +write --document $DOC_ID --text "CHUNK"`

### Step 4: Present results to user
After running, summarize:
- Total tenders found
- Top Priority count + list the best ones with client, deadline, value
- Highlight any with upcoming deadlines
- Link to the Google Doc

## Key files
- `ACME Agency/tenders/scraper.mjs` — Playwright scraper (login, filter, fetch details)
- `ACME Agency/tenders/analyze.mjs` — Title-only keyword scorer
- `ACME Agency/tenders/build_doc.mjs` — Google Doc writer (has Windows shell issues, use bash chunks instead)
- `ACME Agency/tenders/tenders_detailed.json` — Raw scraped data
- `ACME Agency/tenders/tenders_analyzed.json` — Scored & categorized data
- `ACME Agency/tenders/doc_content.txt` — Plain text for Google Doc

## Important notes
- **Tender types:** nadmetanja = active (apply!), dodjele ugovora = awarded (intel only), ispravak/poništenje = corrections
- **"Nije navedeno" deadlines:** means deadline isn't publicly listed — user must check the link
- **01.01.1900 dates:** means "not specified" in the Briefing system
- **Site template noise:** The detail pages include "facebook", "web", "internet" in their nav/footer — NEVER use detail page text for keyword scoring, only use titles
- **gws on Windows:** use bash shell for gws commands, not Node execFileSync (gws not in Node PATH)
- **Google Doc ID:** <id>
- **Tenderi folder ID:** <id>

## ACME Agency context
- Bosnian/Croatian paid ads agency, ~25 clients, team of 8
- Core services: Meta Ads, Google Ads, landing pages, lead gen funnels
- Best-fit tenders: digital marketing, social media, ad campaigns, media buying, branding
- Secondary: events, PR, design, video production
