Best Practices for Conditional Logic in Prompts
# support
h
@Vapi @Vapi Support Bot I’m working on a voice assistant workflow where I need to handle Office Status and Outlet Status independently. The logic looks something like this: ## SYSTEM CONTEXT - Current date and time: {{"now" | date: "%A, %B %d, %Y, %H:%M", "Europe/Berlin"}} - Customer phone number: {{customer.number}} - Office Status: {{office_status}} - Outlet Status: {{outlet_status}} ### A. RETAILERS IF Office Status is OPEN: - Ask: "Is it about questions regarding our products, such as range or ordering, or do you have a complaint?" Routing Rules: - Complaints / Customer Service Requests →
transferCallUK(customer_service)
- Product Questions / Orders →
transferCallUK(sales_uk)
IF Office Status is CLOSED: - Response: "I apologize, but I cannot transfer you to our sales or customer service departments outside of office hours. Our office is open Monday to Friday, 08:00 to 17:00. Please call back during these times, or I can provide you with general information now." --- ## My Question I’m trying to figure out the best way to write conditions in my prompt. Specifically, I want to check Office Status and Outlet Status independently. ## Option 1: Plain Text Condition IF Office Status is OPEN ## Option 2: Variable Comparison {{office_status}} == OPEN ## Option 3: Liquid JS Syntax What about Liquid JS, can I do like {% if office_status == "OPEN" %} office_status is a dynamic variable so in Liquid JS syntax I should use office_status with {{}} or simply above one is correct Which approach works best for LLM clarity and reduces confusion? I’ve noticed that sometimes the model mixes up conditions and gives the apology script even when the office is open, instead of routing the call correctly. - I have many conditional statements in my workflow. - I want to avoid ambiguity and ensure the LLM consistently follows the correct branch.
v
Based on the information available, I do not have specific documentation or official best practices regarding which conditional syntax (plain text, variable comparison, or Liquid JS) is most effective for LLM clarity in your workflow. However, since you are working with dynamic variables like office_status and outlet_status, using a clear and explicit variable comparison (such as
{{office_status}} == "OPEN"
or
{% if office_status == "OPEN" %}
in Liquid syntax) is generally more precise and less ambiguous than plain text conditions. This approach can help ensure that each condition is evaluated independently and consistently, especially when you have many conditional statements. If you are experiencing issues where the model sometimes gives the wrong branch (e.g., the apology script when the office is open), it may be helpful to double-check how the variables are being set and referenced in your workflow, and to use explicit comparisons to reduce ambiguity. If you need more detailed guidance or examples, I do not have further information to provide at this time.
c
use the first option. while using operators and liquidJS syntax helps with standard programming practices and asserts control, using more open language is better consumed by LLMs. LLMs are trained on language and understand words way better than numbers.