Tgt - Checking a store's goal progress from Slack
This use case illustrates a concrete use of the Biron plugin in Zapier. If you are not yet familiar with how it works (authentication, query structure, variable management), please read the Biron × Zapier guide first before continuing.
What we’re building
Section titled “What we’re building”A Zap that triggers when a user adds a reaction to a Slack message. The Zap reads the message content and detects whether any store names are mentioned.
- If no store is detected: a thread reply explains to the user how to phrase their request
- If at least one store is detected: the Zap retrieves the month-to-date results for those stores, sends a summary in thread, then triggers the gap analysis sub-Zap for each of them
Zap architecture
Section titled “Zap architecture”Slack (reaction) → Date calculation → Store list query → Store detection in message ├── Path 1 — No store detected → Slack reply └── Path 2 — Store(s) detected → Results query → Formatting → Slack → Loop (Sub-Zap)Common steps
Section titled “Common steps”Trigger — Slack “New Reaction Added”
Section titled “Trigger — Slack “New Reaction Added””Add a Slack → New Reaction Added block and configure:
- Channel: the channel where the Zap will be active
- Reaction: the emoji reaction that triggers the Zap
Date calculation
Section titled “Date calculation”Biron queries require explicit dates. This block generates them dynamically on each run.
Add a Code by Zapier block (Python). Use the following prompt to generate the code, then paste the result into the block:
Role: Python expert for Zapier.Goal: Create a relative date calculation script.
Calculate the following dates, handling calendar edge cases(leap years, end of month):- Start of current month and Y-1- End of current month and Y-1- Yesterday and yesterday Y-1- 3 months ago and 3 months ago Y-1
Output: return an "output" dictionary with all dates in YYYY-MM-DD format.Store list query
Section titled “Store list query”Create a chart in Biron that retrieves only the names of active stores. Copy the NexusQL and paste it into the Biron Query block.
This list will be used to detect store names in the Slack message that triggered the Zap.
Store detection — Code by Zapier
Section titled “Store detection — Code by Zapier”Add a Code by Zapier block (Python). Use the following prompt to generate the code:
Role: Python expert for Zapier.Goal: Detect which stores from a reference list are mentioned in a text message,and prepare the results for the next steps of the Zap (SQL queries and Loop).
Available inputs (via input_data):- message — raw text in which to search for store names- shop_list — reference list of stores to detect (comma-separated)
Request:For each store in shop_list, detect whether it is mentioned in messageusing case-insensitive search and avoiding false positives on partial words(e.g. "Paris" must not match "Parisian").
For each store found, prepare two formats:- Raw name: Paris- Single-quoted name: 'Paris' (for injection into SQL queries)
Return in output the following keys:- shop_found — boolean, True if at least one store is found- match_count — number of stores found- matched_shops_list — found stores comma-separated (e.g. Paris, Lyon)- matched_shops_quotes — same with single quotes (e.g. 'Paris', 'Lyon')- first_match — first store found, or None if none- loop_shop_names — Python list of raw names (for "Create Loop From Line Items" in Zapier)- loop_shop_quotes — Python list of single-quoted names (for "Create Loop From Line Items" in Zapier)Path 1 — No store detected
Section titled “Path 1 — No store detected”Filter — Path by Zapier
Section titled “Filter — Path by Zapier”Add a Path branch with the following condition:
- Continue only if
boutiques_trouvees_countequals0
Reply — Slack
Section titled “Reply — Slack”Add a Slack block and configure:
- Channel: the trigger channel
- Thread: the
Tsvariable from the message that triggered the Zap - Message Text: a message explaining the correct usage, for example:
No store recognized in this message.To trigger an analysis, make sure your message containsthe exact name of a store (e.g. Paris, Lyon, Bordeaux).Path 2 — Store(s) detected
Section titled “Path 2 — Store(s) detected”Filter — Path by Zapier
Section titled “Filter — Path by Zapier”Add a path branch with the following condition:
- Continue only if
boutiques_trouvees_countis greater than0
Store results query
Section titled “Store results query”For each detected store, retrieve the realized revenue and the current month’s target. Create a chart in Biron filtered on the identified stores, copy the NexusQL and paste it into the Biron Query block. Replace the static dates with the variables produced in the date calculation step.
The calculated columns to add to the query are the same as those in the month-to-date tracking — projected revenue, delta, and achievability category:
ROUND( `CA HT Mois en Cours` + `CA HT (A-1) Mois restant` * `Croissance CA HT 3 derniers mois`, 2) AS `Objectif Prévisionnel CA HT`,
ROUND( 100 * (`Objectif Prévisionnel CA HT` - `Objectif CA HT`) / `Objectif Prévisionnel CA HT`, 2) AS `Delta Pourcent Prévisionnel CA HT`,
CASE WHEN `CA HT Mois en Cours` >= `Objectif CA HT` THEN 'Validé' WHEN `Delta Pourcent Prévisionnel CA HT` < -15 THEN 'Compromis' WHEN `Delta Pourcent Prévisionnel CA HT` < -5 THEN 'Ambitieux' WHEN `Delta Pourcent Prévisionnel CA HT` < 0 THEN 'Court' WHEN `Delta Pourcent Prévisionnel CA HT` < 5 THEN 'Attendu' WHEN `Delta Pourcent Prévisionnel CA HT` < 15 THEN 'Confortable' ELSE 'Garanti'END AS `Prévision Objectif`Formatting — results message
Section titled “Formatting — results message”Add a Code by Zapier block (Python) and use this prompt to generate the code:
Role: Python expert for Zapier.Goal: Generate a Slack target tracking message for the requested stores.
Available inputs (via input_data):- shops: store names (comma-separated list)- labels: category of each store (comma-separated list)- billing_target: revenue target (comma-separated list)- billing_real: realized revenue since start of month (comma-separated list)
Request:1. Format all amounts in euros using French number format: thousands separator = space, decimals = comma (e.g. 12 345,67€).2. Group stores by category in this order, with the associated emoji: ✅ Validated | 🟣 Guaranteed | 🔵 Comfortable | 🟢 On track | 🟡 Short | 🟠 Ambitious | 🔴 At risk3. For each store, display: • *Store name*: _Realized_ 12 345,67€ | _Target_ 15 000,00€ If the category is not Validated, add the remaining gap: | -2 654,33€4. Generate a Slack message slack_message_formatted with: - Bold title: *Target Analysis as of {DD/MM/YYYY}* - Store groups (empty categories not displayed)5. Return the result in output with the key slack_message_formatted.Send — Slack
Section titled “Send — Slack”Add a Slack block and configure:
- Channel: the trigger channel
- Thread: the
Tsvariable from the message that triggered the Zap - Message Text: the
slack_message_formattedvariable produced by the formatting block
Loop — Looping by Zapier
Section titled “Loop — Looping by Zapier”Add a Looping by Zapier block, passing it the store names and their Prévision Objectif from the results query.
Launch sub-Zap — gap analysis
Section titled “Launch sub-Zap — gap analysis”For each store in the loop, trigger the gap analysis sub-Zap by passing:
| Variable | Value to pass |
|---|---|
start_date | Start of current month (date calculation step) |
end_date | Yesterday (date calculation step) |
shop_id | Store name (current loop iteration) |
slack_ts | TS of the Slack message sent in the previous step |
Expected result
Section titled “Expected result”The user adds a reaction to a Slack message containing one or more store names. Within seconds, a thread reply shows the current target status for those stores — followed by a detailed gap analysis for each of them.
If the message contains no recognized store name, the user receives a help message explaining how to phrase their request.