This guide explains how to create dynamic, conditional-based calculations inside a Mini App using form inputs and logic.
1. Use Case Overview #
In this example, we are building an event registration form where:
- Users enter basic details (Name, District, WhatsApp Number, etc.)
- Users select the number of packs (1–4)
- Based on the selection, additional fields dynamically appear
- A final summary screen calculates total payable amount
2. Dynamic Field Visibility #
Field visibility is controlled using conditions:
- If Number of Packs ≥ 2 → Show fields for Person 2
- If Number of Packs ≥ 3 → Show fields for Person 3
- If Number of Packs = 4 → Show fields for Person 4
Note: Conditional visibility works only for input components, not for text or heading elements.
3. Visitor Details Logic #
Each visitor includes:
- Full Name
- Gender
- Date of Birth
- Stay Required (Yes/No)
Pricing Logic: #
- Stay = Yes → ₹2500
- Stay = No → ₹750
- Field not present → ₹0
4. Creating Conditional Calculations #
To calculate totals dynamically:
- Define logic using if-else conditions
- Convert logic into JavaScript ternary expressions
Example Logic:Copy
If Stay = Yes → 2500
If Stay = No → 750
Else → 0
Combined Formula (for multiple users):
- Add conditions for each person (Person 1 to Person 4)
- Sum all calculated values
5. Using ChatGPT for Formula Generation #
You can generate formulas using prompts like:
“Write this logic using ternary operator in JavaScript”
Then:
- Copy only the formula (ignore extra text)
- Replace static values with dynamic field variables
6. Implementing in Mini App #
- Add calculation logic inside the same screen (Summary Screen)
- Replace variables with actual field mappings
- Save the calculation as a data source
7. Important Step (Mapping Fix) #
Before using the formula:
- Add a test calculation (e.g.,
4 + 4) - Click Run & Save
- This enables the output to appear in history
- Now replace it with your actual formula
- Map it inside the text/body field
Do not click “Run & Save” again after adding the real formula (no live data available)
8. Displaying Calculated Values #
You can display:
- Total number of packs
- Packs with stay
- Packs without stay
- Total payable amount
All values are dynamically mapped from the calculation fields.
9. Key Tips #
- Always create logic first, then convert to formula
- Use dynamic variables from previous screens
- Keep calculations on the same screen where output is needed
- Use images or dotted text to visually separate sections (WhatsApp UI limitation)
Mini App Template: DASHBOARD_URL /products/flows/share/8c7400c2-92d2-4b49-8809-dd21136c17ba