> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dify.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Lesson 7: Enhance Workflows (Plugins)

Our email assistant can now flip through our knowledge base. But what if a customer asks a beyond-knowledge-base question, like: What is in the latest Dify release?

If the knowledge base hasn't been updated yet, the workflow will be at a loss. To fix this, we need to equip it with a Live Search skill!

## Tools

<Frame>
  <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/tools.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=a7d2f9893090e75728812ee28af04e99" alt="Tools" width="2908" height="1504" data-path="images/use-dify/tutorial/workflow-101-lesson-07/tools.png" />
</Frame>

Tools are the superpower for your AI workflow.

The [Dify Marketplace](https://marketplace.dify.ai/) is like a Plugin Supermarket. It's filled with ready-made superpowers—searching Google, checking the weather, drawing images, or calculating complex math. You just install and plug them into your workflow with several clicks.

Now, let's continue to upgrade on current workflow.

### Hands-On 1: Upgrade the Sub-process Area in Iteration

We are going to add a new logic to our assistant: Check the Knowledge Base first; if the answer isn't there, go search Google.

To focus on the new logic, let's keep only these nodes: **User input, Parameter Extractor, and Iteration**.

#### Step 1: Knowledge Query and the Judge

<Steps>
  <Step title="Enter the Iteration">
    1. Click to enter the sub-process area of the Iteration node.
    2. Keep Knowledge Retrieval node, and make sure the query variable is `{x} item`.
    3. Delete the previous LLM node.
  </Step>

  <Step title="Add the Judge (LLM Node)">
    Add an LLM node right after Knowledge Retrieval node. Its job is to decide if the Knowledge Base info can actually respond to the questions.

    * **For Context session**: Select the `Knowledge Retrieval / {x} result Array [Object]` from Knowledge Retrieval
    * **System Prompt**:

    ```plaintext wrap theme={null}
    Based on the `Context`, determine if the answer contains enough information to answer the questions. If the information is insufficient, you MUST reply with: "Information not found in knowledge base".
    ```

    * **User Message**:

    ```plaintext wrap theme={null}
    questions: Iteration/{x} item
    ```

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/llm-settings.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=8ca072a02a0a36e8bf449234472937bd" alt="LLM Settings" width="1232" height="1062" data-path="images/use-dify/tutorial/workflow-101-lesson-07/llm-settings.png" />
    </Frame>
  </Step>
</Steps>

Here's what it looks like on the canvas.

<Frame>
  <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/workflow-preview-01.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=09ea57b2cd18f37a13d5b3a830562374" alt="Workflow Preview" width="2238" height="320" data-path="images/use-dify/tutorial/workflow-101-lesson-07/workflow-preview-01.png" />
</Frame>

#### Step 2: Setting the Crossroads

<Steps>
  <Step title="Add If/Else Node">
    After LLM node, let's add If/Else node. Set the rule: If LLM Output **Contains** **Information not found in knowledge base**.

    This means, when we can't respond with the information in knowledge base.

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/add-if-else-node.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=3d0db66feff198e99e2f582f273986a0" alt="Add if/Else Node" width="1220" height="496" data-path="images/use-dify/tutorial/workflow-101-lesson-07/add-if-else-node.png" />
    </Frame>
  </Step>

  <Step title="Add Tool for Searching">
    Let's connect a search tool after the IF branch. This indicates that when the knowledge base cannot find relevant answer information, we use web search to find the answers.

    1. After the IF node, click plus(+) icon and select Tool.
    2. In the search box, type Google. Hover over Google, click Install on the right, and then click Install again in the pop-up window.

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/add-tools.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=10c4993c15033921ca01090ca2381277" alt="Install Plugin" width="1167" height="689" data-path="images/use-dify/tutorial/workflow-101-lesson-07/add-tools.png" />
    </Frame>
  </Step>

  <Step title="Install Google Search">
    Click Google Search in Google.

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/install-google-search.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=acc651f43572399fc42840b3bd6cfe00" alt="Install Google Search" width="1166" height="744" data-path="images/use-dify/tutorial/workflow-101-lesson-07/install-google-search.png" />
    </Frame>
  </Step>

  <Step title="Get Your API Key">
    Using Google Search for the first time requires authorization—it's like needing a Wi-Fi password.

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/google-search-setup.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=029d8fc7fcbd6ad89c0b19a5974cb063" alt="Google Search Setup" width="1224" height="282" data-path="images/use-dify/tutorial/workflow-101-lesson-07/google-search-setup.png" />
    </Frame>

    1. Click API Key Authorization Configuration, then click Get your SerpApi API key from SerpApi. Sign in to get your private API key.

           <Note>
             Your API Key is your passport to the outside world. Keep it safe and avoid sharing it with others.
           </Note>

           <Frame>
             <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/api-key-authorization-configuration.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=8fc65a662404c58b6261aadfdaf87214" alt="API Key Authorization Configuration" width="1330" height="968" data-path="images/use-dify/tutorial/workflow-101-lesson-07/api-key-authorization-configuration.png" />
           </Frame>
    2. Copy and paste the API key in SerpApi API key. Click **Save**.
    3. Once the API key is successfully authorized, the settings panel shows up immediately. Head to Query string field, and select `Iteration/{x} item`.

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/add-query-string.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=061ead7cc1294bb1a5ab645e891b9fc8" alt="Add Query String" width="1194" height="524" data-path="images/use-dify/tutorial/workflow-101-lesson-07/add-query-string.png" />
    </Frame>
  </Step>

  <Step title="Configure the Two Paths">
    Now, we need different ways to answer depending on which path we're looking at.

    **The Search Answer Path**

    Add a new LLM node to answer the question based on the search results. Connect it to the Google Search node.

    **System**:

    ```plaintext wrap theme={null}
    You are a Web Research Specialist. Based on Google Search, concisely answer the user's questions. Please do not mention the knowledge base in your response.
    ```

    **User Message**:

    ```plaintext wrap theme={null}
    results: GOOGLESEARCH/{x} text
    questions: Iteration/{x} item
    ```

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/llm-02-prompt.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=51edf106a23512f3c1e0fe78b2e9a1aa" alt="Prompt for LLM 2" width="2248" height="1034" data-path="images/use-dify/tutorial/workflow-101-lesson-07/llm-02-prompt.png" />
    </Frame>

    **The Knowledge Searching Path**

    After the Else node, add a new LLM node to handle answers based on the knowledge base.

    **System**:

    ```plaintext wrap theme={null}
    You are a professional Dify Customer Service Manager. Strictly follow the `Context` to reply to questions.
    ```

    **User Message**:

    ```plaintext wrap theme={null}
    questions: Iteration/{x} item
    ```

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/prompt-llm-03.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=83ed88e6060b2269c9b9e44ab4a14256" alt="Prompt for LLM 3" width="1918" height="1034" data-path="images/use-dify/tutorial/workflow-101-lesson-07/prompt-llm-03.png" />
    </Frame>
  </Step>

  <Step title="Combine the Information">
    1. In the sub-process (inside the Iteration box), add a Variable Aggregator node that connects both LLM 2 and LLM 3 at the very end.
    2. In the Variable Aggregator panel, select the variables `LLM 2/{x}text String` and `LLM 3/{x}text String` as the Assign Variables.

    In this way, we're merging the two possible answers into a single path.

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/variable-aggregator-setup.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=c70fbfd6de71090fd624be565974d0fe" alt="Variable Aggregator Setup" width="1170" height="544" data-path="images/use-dify/tutorial/workflow-101-lesson-07/variable-aggregator-setup.png" />
    </Frame>
  </Step>
</Steps>

This is how the current workflow looks.

<Frame>
  <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/workflow-preview-02.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=58b45b8ce8fcf993305833399a5e452f" alt="Workflow Preview 2" width="2612" height="544" data-path="images/use-dify/tutorial/workflow-101-lesson-07/workflow-preview-02.png" />
</Frame>

#### Step 3: The Final Email Assembly

Now that our logic branches have finished processing, let's combine all the answers into a single, polished email.

<Steps>
  <Step title="Configure Iteration Output">
    Click on the Iteration node, and set `{x}Variable Aggregator/{x}output String` as the output variables.

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/iteration-output.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=b99ca355d9ed170f0cfe2cf12ada51f7" alt="Iteration Output" width="1152" height="580" data-path="images/use-dify/tutorial/workflow-101-lesson-07/iteration-output.png" />
    </Frame>
  </Step>

  <Step title="Connect the Summary LLM">
    After the Iteration node, connect a new LLM node to summarize all outputs. Feel free to use the prompt below.

    **System**:

    ```plaintext wrap theme={null}
    You are a professional Customer Service Manager. Summarize all the answers of the questions, and organize a clear and complete email reply for the customer.
    Do not include content where the knowledge base could not find relevant information.
    Signature: Anne.
    ```

    **User Message**:

    ```plaintext wrap theme={null}
    questions: Iteration/ {x} output
    customer: User Input / {x} customer_name
    ```

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/prompt-for-llm-04.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=8e5a435fa992e20b2106ae8085f8bc5c" alt="Prompt for LLM 4" width="2036" height="1048" data-path="images/use-dify/tutorial/workflow-101-lesson-07/prompt-for-llm-04.png" />
    </Frame>
  </Step>

  <Step title="Finalize with the Output Node">
    After the LLM node, add an End node. Set the output variable as `LLM 4/{x}text String`.

    <Frame>
      <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/output-setup.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=9cdd47e8d22e3d612c7ded36c5ac266e" alt="Output Setup" width="1152" height="452" data-path="images/use-dify/tutorial/workflow-101-lesson-07/output-setup.png" />
    </Frame>
  </Step>
</Steps>

We have now completed the entire setup and configuration of the workflow. Our email assistant can now answer questions based on the Knowledge Base and use Google Search for supplementary answers when needed.

<Frame>
  <img src="https://mintcdn.com/dify-6c0370d8/W-660XSNevX1HYUo/images/use-dify/tutorial/workflow-101-lesson-07/final-workflow-preview.png?fit=max&auto=format&n=W-660XSNevX1HYUo&q=85&s=f391b828fb3984c303a60bca368c1705" alt="Final Workflow Preview" width="2656" height="452" data-path="images/use-dify/tutorial/workflow-101-lesson-07/final-workflow-preview.png" />
</Frame>

Try sending an email with question that definitely isn't in the knowledge base. Let's see if the AI successfully uses Google to find the related answers.

## Mini Challenge

1. What are other conditions you can choose in If/Else node?
2. Browse marketplace to see if you can add another tool for this workflow?
