enrich_emails.py

entry point
137 steps Google Auth Google Sheets HTTP Client cli: __main__ guard cli: argparse

This automation script reads contact information from a Google Sheet, uses the Anymailfinder service to find missing email addresses for those contacts, and then updates the Google Sheet with the newly found email addresses.

Flow

Click any step to see details

graph TB
  n_enrich_emails_get_credentials_compact[["get_credentials() — 13 steps (7 Decision, 3 Output, 3 File I/O)"]]:::compact
  n_enrich_emails_find_email_with_anymailfinder_compact[["find_email_with_anymailfinder() — 12 steps (9 Decision, 2 Output, 1 API)"]]:::compact
  n_enrich_emails_create_bulk_search_compact[["create_bulk_search() — 10 steps (4 Decision, 4 Output, 1 Transform, 1 API)"]]:::compact
  n_enrich_emails_poll_bulk_search_status_compact[["poll_bulk_search_status() — 13 steps (6 Decision, 6 Output, 1 API)"]]:::compact
  subgraph n_enrich_emails_download_bulk_results["download_bulk_results()"]
    n_enrich_emails_228{"if not api_key"}:::decision
    n_enrich_emails_236{"try/except block"}:::decision
    n_enrich_emails_237["API: requests.get()"]:::api
    n_enrich_emails_242(["Output: print()"]):::output
    n_enrich_emails_242[["Transform: len()"]]:::transform
    n_enrich_emails_246(["Output: print()"]):::output
    n_enrich_emails_228 --> n_enrich_emails_236
    n_enrich_emails_236 --> n_enrich_emails_237
    n_enrich_emails_237 --> n_enrich_emails_242
    n_enrich_emails_242 --> n_enrich_emails_242
    n_enrich_emails_242 --> n_enrich_emails_246
  end
  n_enrich_emails_enrich_sheet_compact[["enrich_sheet() — 35 steps (14 Transform, 11 Decision, 9 Output, 1 API)"]]:::compact
  n_enrich_emails_enrich_with_bulk_api_compact[["enrich_with_bulk_api() — 25 steps (10 Output, 8 Decision, 7 Transform)"]]:::compact
  subgraph n_enrich_emails_enrich_row["enrich_row()"]
    n_enrich_emails_413(["Output: print()"]):::output
  end
  n_enrich_emails_enrich_with_concurrent_api_compact[["enrich_with_concurrent_api() — 19 steps (9 Output, 6 Decision, 4 Transform)"]]:::compact
  subgraph n_enrich_emails_main["main()"]
    n_enrich_emails_504{"if result_url"}:::decision
    n_enrich_emails_505(["Output: print()"]):::output
    n_enrich_emails_507(["Output: print()"]):::output
    n_enrich_emails_504 --> n_enrich_emails_505
    n_enrich_emails_505 --> n_enrich_emails_507
  end
  click n_enrich_emails_228 call showStepDetail("enrich_emails.py", 228)
  click n_enrich_emails_236 call showStepDetail("enrich_emails.py", 236)
  click n_enrich_emails_237 call showStepDetail("enrich_emails.py", 237)
  click n_enrich_emails_242 call showStepDetail("enrich_emails.py", 242)
  click n_enrich_emails_242 call showStepDetail("enrich_emails.py", 242)
  click n_enrich_emails_246 call showStepDetail("enrich_emails.py", 246)
  click n_enrich_emails_413 call showStepDetail("enrich_emails.py", 413)
  click n_enrich_emails_504 call showStepDetail("enrich_emails.py", 504)
  click n_enrich_emails_505 call showStepDetail("enrich_emails.py", 505)
  click n_enrich_emails_507 call showStepDetail("enrich_emails.py", 507)
classDef api fill:#dbeafe,stroke:#2563eb,color:#1e3a5f
classDef fileio fill:#dcfce7,stroke:#16a34a,color:#14532d
classDef dbop fill:#f3e8ff,stroke:#9333ea,color:#3b0764
classDef decision fill:#ffedd5,stroke:#ea580c,color:#7c2d12
classDef output fill:#f3f4f6,stroke:#6b7280,color:#1f2937
classDef transform fill:#ccfbf1,stroke:#0d9488,color:#134e4a
classDef entry fill:#dcfce7,stroke:#16a34a,stroke-width:3px,color:#14532d
classDef compact fill:#f0f4ff,stroke:#6366f1,color:#312e81,stroke-width:2px
                    
API Call File I/O Database Decision Output Transform

All Steps

Step Detail

Select a step from the diagram or list to see its details.

Services

  • Google Auth (google.oauth2)
  • Google Sheets (gspread)
  • HTTP Client (requests)

Secrets

  • ANYMAILFINDER_API_KEY
  • GOOGLE_APPLICATION_CREDENTIALS

Imports

External

  • argparse
  • concurrent.futures
  • dotenv
  • google.auth.transport.requests
  • google.oauth2.credentials
  • google.oauth2.service_account
  • google_auth_oauthlib.flow
  • gspread
  • json
  • os
  • requests
  • sys
  • time