Skip to main content
Right now, our Email Assistant treats every message following the same path of the workflow. That’s not smart enough. An email asking about Dify’s price should be handled differently than an email on bug reporting. To make our assistant truly intelligent, we need to teach it how to Read the Room. We’re going to set up a Crossroads that sends different types of emails down different tracks.

The If/Else Node

If/Else Node
If/Else node is just like a traffic light. It checks a condition (like Does this email mention pricing? ) and sends the flow left or right based on the result.

Hands-On 1: Set up the Crossroads

Let’s upgrade our assistant so it can tell the difference between Dify-related emails and Everything else.
1

Insert the Node

Hover over the line between the Start and Knowledge Retrieval nodes. Click the Plus (+) icon and select the If/Else node.
2

Set the Rules

  1. Click the node to open the panel
  2. Click + Add Condition in the IF section. Choose the variable: {x} email_content
Add Condition
  1. The Logic: Keep it as Contains. Type Dify in the input box
Contains
Now, the complete logic for the IF branch is: If the email content contains the word Dify.
Understanding the Traffic LightWhen setting conditions, Dify offers several ways to judge information, much like the different signals at a crossroads:
  • Is / Is Not Like a perfect key for a lock. The content must match your value exactly.
  • Contains / Not Contains Like a magnifying glass. It checks if a specific keyword exists anywhere in the text. This is what we are using today.
  • Starts with / Ends with Check if the text begins or ends with specific characters.
  • Is Empty / Is Not Empty Check if the variable has any content. For example: Checking if a user actually uploaded an attachment. Understanding these helps you set accurate and flexible rules, building a much smarter workflow!

Hands-On 2: Plan Different Paths

Now that we have the crossroad here, we need to decide what happens on each road. Click the plus (+) icon on the right side of the IF branch, drag out a line, and connect it to Knowledge Retrieval node. What this means: When the email contains the word Dify, the flow will execute the professional reply process we built in the last lesson (which looks up information in the Knowledge Base).
Connect IF Branch

B. The Unrelated Email Track (ELSE Branch)

For emails that are not related or mention Dify, we want to create a simple, polite, and general reply process.
1

Create a new Node

Click the (+) next to ELSE and select a new LLM Node (LLM 2)
2

Add Prompt to this LLM node

Copy and paste the prompt below
You are a professional customer service manager. Based on the customer's email, kindly inform the user that no relevant information was found and provide relevant guidance.

Requirements:
1. Address the customer name in a friendly tone.
2. Thank them for their letter.
3. Keep the tone professional and friendly.
4. Sign off as "Anne."
3

Add User Message

  1. Click Add Message button below system.
  2. In the User Message box, type customer name:.
  3. Press / on your keyboard.
  4. You can see the Variable Selection menu pops out, and click customer_name.
  5. Press Enter to start a new line, and type email content:
  6. Press the / key again and click on email_content.
Prompt for LLM 2
Now we have two tracks generating two different replies. Imagine if we had 10 tracks, our workflow would look like a messy plate of spaghetti. To keep things clean, we use a Variable Aggregator. Think of it as a Traffic Hub where all the different roads merge back into one main highway.

Variable Aggregator

Variable Aggregator
Variable Aggregator is like a traffic hub where all the different roads merge back into one main highway.

Hands-On 3: Add Variable Aggregator

1

Add the Aggregator

  1. Select the connection line between the End Node and the LLM node and delete it.
  2. Right-click on the canvas, select Add Node, and choose the Variable Aggregator node.
Add Variable Aggregator
2

Merge the Paths

Connect LLM and LLM 2 node to the Variable Aggregator.
3

Assign the Output

  1. Click the Variable Aggregator node.
  2. Click the plus (+) icon next to Assign Variables.
  3. Select the text from LLM 1 AND the text from LLM 2.
Assign Variable
Now, no matter which LLM node generates the response, the Variable Aggregator node gathers the content and hands it to the Output Node.
4

The Final Step

  1. Connect the Variable Aggregator to the Output node.
  2. Update the Output Variable to the Variable Aggregator’s result instead of previous LLM results.
Update Output Variable
Here’s how the workflow looks:
Final Workflow
5

Test and Run

Click Test Run, enter a customer name, and try testing with inputs that both include and exclude the keyword Dify to see the different results.

Mini Challenge

For business inquiry emails, how should we edit this workflow to generate proper response?
Don’t forget to update knowledge base with business-related files.