Tom  Kuhl
Tom Kuhl16mo ago

Using conditions with multiple blocks

I prompted GPT4 to build a date range selection function to return weather forecast data for upcoming trips to a destination. It works by asking for an arrival data and departure date then assigns them a day number from the current date. For example: Today is 05/14/2024 which is returned as Day0 with a value of 0. If a traveler gives a arrival date of 05/15/2024 and a departure date of 05/17/2024 the function returns the following: Day0 = 0 Day1 = 1 Day2 = 1 Day3 = 1 Day4 = 0 Day5 = 0 etc… With the function working, I setup conditions for all the days: If Day0 is 1 If Day1 is 1 If Day2 is 1 etc… Then I set up text blocks to test the flow, expecting the above examples of travels days to hit the blocks for Day1, Day2, and Day3, but as you can see by the screenshot, it only hit Day1 then stopped. Because the API charges by the call and not by the token, I’ve been calling before the function and pulling all the data. The function is then intended to tell the bot what days to display data for. Anyone have suggestions on setting up a better flow or know how with the current flow that I can hit multiple text blocks when a value of 1 is returned?
No description
1 Reply
Tico | Voiceflow Assistant
To set up a flow that hits multiple text blocks based on the returned day values, you can use the Condition Step in Voiceflow to evaluate each day and direct the conversation accordingly. Here’s how you can achieve this: 1. Create Variables for Each Day: Ensure you have variables like Day0, Day1, Day2, etc., which will hold the values returned by your function. 2. Set Up Condition Steps: - Add a Condition Step for each day you want to evaluate. - In each Condition Step, add a condition to check if the day variable equals 1. 3. Add Actions to Conditions: - For each condition that evaluates to true, add an action to go to the corresponding text block. - For example, if Day1 equals 1, the action should direct to the text block for Day1. 4. Nesting Conditions: - You can nest multiple conditions within a single Condition Step to evaluate multiple days. - Use the Add Condition button to add more conditions within the same step. Here’s a simplified example of how to set up the conditions:
**Condition Step for Day1**:
- Condition: If `Day1` equals `1`
- Action: Go to `Text Block for Day1`

**Condition Step for Day2**:
- Condition: If `Day2` equals `1`
- Action: Go to `Text Block for Day2`

**Condition Step for Day3**:
- Condition: If `Day3` equals `1`
- Action: Go to `Text Block for Day3`
**Condition Step for Day1**:
- Condition: If `Day1` equals `1`
- Action: Go to `Text Block for Day1`

**Condition Step for Day2**:
- Condition: If `Day2` equals `1`
- Action: Go to `Text Block for Day2`

**Condition Step for Day3**:
- Condition: If `Day3` equals `1`
- Action: Go to `Text Block for Day3`
5. Ensure Sequential Flow: - Make sure the conditions are evaluated sequentially and that the conversation flow continues to the next condition after each evaluation. 6. Testing: - Test your flow to ensure that it correctly evaluates each day and directs to the appropriate text blocks. By setting up your conditions this way, you can ensure that multiple text blocks are hit based on the values returned by your function. For more detailed guidance, you can refer to the Voiceflow documentation on Condition Steps.

Did you find this page helpful?