Files
bussines_case_automation/llm_prompt_retail_media.md
andrei 0e2e1bddba Add xlsxwriter-based Excel generation scripts with openpyxl implementation
- Created create_excel_xlsxwriter.py and update_excel_xlsxwriter.py
- Uses openpyxl exclusively to preserve Excel formatting and formulas
- Updated server.js to use new xlsxwriter scripts for form submissions
- Maintains all original functionality while ensuring proper Excel file handling

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-22 13:53:06 +00:00

3.3 KiB
Raw Blame History

🧠 LLM Prompt Retail Media Calculation Agent

Purpose

You are a smart data agent. Your job is to:

  1. Extract input values from the existing form ( index.html).
  2. Read constants and formulas from an existing config.json.
  3. Normalize input:
    • For any question that asks for a percentage (e.g., "percentage of stores with screens"), divide that value by 100 before using it in calculations.
  4. Apply the formulas to calculate the following metrics and insert the values into results.json under the following keys:
{
  "potential_reach_in_store": <calculated_value>,
  "unique_impressions_in_store": <calculated_value>,
  "potential_reach_on_site": <calculated_value>,
  "unique_impressions_on_site": <calculated_value>,
  "potential_reach_off_site": <calculated_value>,
  "unique_impressions_off_site": <calculated_value>
}

🔢 Formulas

  • % stores with retail media
    = min(stores_with_screens, stores_with_radio) + abs(stores_with_screens - stores_with_radio) / 2

  • potential_reach_in_store
    = (transactions × % stores with retail media / frequency) × visitor_coefficient

  • unique_impressions_in_store
    = ((dwell_time + 60 × ad_duration) × frequency × capture_rate_screen × paid_screen × screen_count) + ((dwell_time + 60 × ad_duration) × frequency × (radio_percentage / 0.5) × paid_radio)

  • potential_reach_on_site
    = (website_visits × (1 - website_bounce_rate) / website_frequency) + (app_users × (1 - app_bounce_rate)) + (loyalty_users × (1 - loyalty_bounce_rate))

  • unique_impressions_on_site
    = average_impressions_website × website_frequency × if_website + average_impressions_app × app_frequency × if_app + average_impressions_loyalty × loyalty_frequency × if_loyalty

  • potential_reach_off_site
    = sum of (followers × (1 - off_site_bounce_rate)) for each channel selected

  • unique_impressions_off_site
    = frequency × avg_impressions × if_channel for each selected channel (e.g., Facebook, Instagram, etc.)


Boolean Inputs

Use if_channel = 1 if selected, 0 otherwise.


⚙️ Additional Behavior

After the user clicks the Submit button on the form:

  • The formulas must be executed using the inputs.
  • The calculated values must be generated and replaced into the results.json.
  • This logic should be implemented in a separate script file responsible for handling the form submission, reading constants, applying formulas, and updating the config.

📁 Output: results.json

We maintain a JSON file named results.json with the following structure:

{
  "potential_reach_in_store": <calculated_value>,
  "unique_impressions_in_store": <calculated_value>,
  "potential_reach_on_site": <calculated_value>,
  "unique_impressions_on_site": <calculated_value>,
  "potential_reach_off_site": <calculated_value>,
  "unique_impressions_off_site": <calculated_value>
}

On each form submission, the formulas must be:

  • Executed using the latest input values
  • The results.json file must be updated (overwritten) with the new results

This logic is to be implemented in Node.js, in a dedicated script that handles:

  • Reading user input
  • Parsing config.json
  • Performing calculations
  • Writing updated values into results.json