Skip to content

Recipe: Federal RFP Scout

This recipe walks you through building an automated RFP scouting workflow using Pencel's built-in primitives. When you're done, you'll have a workflow that:

  • Pulls federal contract opportunities from sam.gov
  • Stages each opportunity as a typed record for in-context scoring
  • Deduplicates against previous runs via promoted seen_items
  • Scores each opportunity against your criteria using a guideline
  • Produces a digest document with only the relevant opportunities

Time to set up: ~15 minutes Runs unattended afterward: Yes (schedule it)


Step 1: Get a sam.gov API key

  1. Go to https://sam.gov/content/entity-registration
  2. Register for an account (or sign in)
  3. Request an API key from https://open.gsa.gov/api/get-opportunities-public-api/
  4. Copy your API key — you'll need it in the next step

Step 2: Store your API key in Pencel

  1. Open Settings > Credentials
  2. Click Add Credential
  3. Fill in:
    • Name: sam-gov
    • Field: apiKey
    • Value: (paste your API key)
  4. Click Save

Your API key is now encrypted in your OS keychain. Pencel agents can access it via the use_credential tool, but the value is automatically redacted from all logs, traces, and memory.

Step 3: Create a scoring guideline

  1. Go to the Knowledge page
  2. Create a new guideline with these rules:
Score each federal opportunity 0-100 using these criteria:

- 40 points if the primary NAICS code is in [541330, 541512, 541511, 541519, 541690]
- 30 points if the estimated value is > $50,000 (or if no value is listed, give 15 points)
- 30 points if the response deadline is more than 5 business days away

Only recommend opportunities scoring 70 or higher. For each recommended opportunity, include:
- Title, solicitation number, and link
- NAICS code and estimated value
- Response deadline
- One-sentence summary of why it scored well

Set the activation mode to Always active (or scope it to your RFP scout agent).

Step 4: Create the workflow from template

  1. Go to Workflows
  2. Click New Workflow
  3. Select the RFP Scout template
  4. Review the instructions — they tell the agent exactly how to fetch, stage, score, and finalize

Step 5: Run it manually first

  1. Open the workflow and click Run
  2. Watch the agent:
    • Call use_credential to get the API key
    • Call fetch_web to pull opportunities from sam.gov
    • Call filter_unseen to drop duplicates from previous runs
    • Call stage_record for each new opportunity (typed record with NAICS, value, deadline)
    • Call query_records to pull all staged opportunities into context for scoring
    • Score each opportunity against your guideline
    • Call finalize_records with promoteToSeenStream: "rfp:federal" for qualifying opportunities — this marks them as finalized AND adds them to the cross-run dedup stream in one call
    • Output a digest document
  3. Review the digest — does it match your expectations?

Step 6: Schedule it

  1. Open the workflow settings
  2. Add a Schedule trigger (e.g., every weekday at 8:00 AM)
  3. If the agent ever needs your input during a scheduled run, you'll get a desktop notification

How it works: the stage → query → finalize pattern

The key insight is that stage_record / query_records / finalize_records give the agent a working memory outside the conversation context:

  1. Stage each fetched opportunity as a typed record. This externalizes the data so the context window stays clean even with hundreds of items.
  2. Query the staged records back when it's time to score. The agent can filter, page, and review them without keeping everything in-context the whole time.
  3. Finalize the qualifying records. When you pass promoteToSeenStream, finalization also marks the keys in seen_items — so the next run's filter_unseen automatically skips them. No separate mark_seen step needed.

Adapting for other sources

This same pattern works for any API that returns JSON:

  1. Store the credentials in Settings > Credentials
  2. Update the workflow instructions to call a different URL via fetch_web
  3. Adjust the scoring guideline for your criteria
  4. Use a different collection name in stage_record and a different stream in promoteToSeenStream (e.g., "rfp:state-dot")

No code changes needed — just update the workflow instructions and guideline text.