Tgt - Notifying when a store hits its monthly target
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”Two complementary Zaps:
- Main Zap — triggers every weekday morning, detects stores that have reached their monthly target since the previous day, and sends a Slack notification. A memory system ensures a store only receives the alert once per month.
- Reset Zap — runs on the 1st of each month to clear the memory and reset the system.
Architecture
Section titled “Architecture”Main Zap
Schedule → Date calculation → Store query → Loop (Storage check → Filter → Slack → Storage write)Reset Zap
Schedule → Storage cleanupMain Zap
Section titled “Main Zap”Trigger — Schedule by Zapier
Section titled “Trigger — Schedule by Zapier”Configure a Schedule by Zapier block:
- Frequency: Every Week
- Days: Monday, Tuesday, Wednesday, Thursday, Friday
- Time: 9:00 AM
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):- Yesterday- Start of month- End of month
Output: return an "output" dictionary with all dates in YYYY-MM-DD format.Store query — monthly target
Section titled “Store query — monthly target”Create a per-store chart in Biron retrieving the current month’s revenue and the monthly target. Copy the generated NexusQL, paste it into the Biron Query block in Zapier, then replace the static dates with the variables produced in the previous step.
Add the following condition to the query to automatically filter and return only stores that have exceeded their target (adapt metric names to match your query):
WHERE `CA HT Mois En Cours` >= `Objectif CA HT`Loop — Looping by Zapier
Section titled “Loop — Looping by Zapier”Add a Looping by Zapier block, passing it only the store names from the previous query.
The loop iterates over each store that has exceeded its target and executes the following four steps for each of them.
Storage check — Storage by Zapier
Section titled “Storage check — Storage by Zapier”For each store, retrieve the value shop_reached_target_[Store Name] from Zapier Storage.
If this key exists, the store has already been notified this month. If it is absent, the store has just reached its target.
Filter — Filter by Zapier
Section titled “Filter — Filter by Zapier”Add a Filter block with the following condition:
- Continue only if
shop_reached_target_[Store Name]does not exist in storage
Already-notified stores are stopped here. New ones proceed to the next step.
Notification — Slack
Section titled “Notification — Slack”Add a Slack block and configure:
- Channel: the channel where the celebration should be sent
- Message Text: a message indicating that the store has reached its monthly target, with the revenue and target variables from the Biron query
Storage write — Storage by Zapier
Section titled “Storage write — Storage by Zapier”Once the message is sent, write the key shop_reached_target_[Store Name] into Zapier Storage to block subsequent notifications until the monthly reset.
Reset Zap
Section titled “Reset Zap”This Zap clears all memory keys each month to allow the main Zap to start fresh.
Trigger — Schedule by Zapier
Section titled “Trigger — Schedule by Zapier”Configure a Schedule by Zapier block:
- Frequency: Every Month
- Day: 1
- Time: 2:00 AM
Storage cleanup — Code by Zapier
Section titled “Storage cleanup — Code by Zapier”Add a Code by Zapier block (Python). Use the following prompt to generate the code, then paste the result into the block:
I want to clean up data stored in Zapier Storage.I have entries whose name starts with shop_reached_target_ and I wantto delete all of them automatically.
Write me the Python code for a "Code by Zapier" step that:1. Connects to Zapier Storage using a secret key that I will add to the code2. Retrieves all stored entries3. Deletes only those whose name starts with shop_reached_target_Expected result
Section titled “Expected result”As soon as a store crosses its monthly target, your team receives a Slack notification — once per month, regardless of how often the Zap runs. On the 1st of each month, the memory is cleared and the cycle starts again.