From Bright Pattern Documentation

Revision as of 16:39, 4 March 2026 by Laura.donovan (talk | contribs) (Updated via BpClonePage extension. Source page: draft:Scenario-builder-reference-guide/Exercises/HowtoAutomateEmailHandlingwithAI)

< Previous | Next >
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How to Automate Email Handling with AI

The Ask AI scenario block lets you leverage your AI of choice to automate almost any part of an interaction. For instance, AI can be used in email scenarios to automatically categorize, draft, and analyze customer emails, improving productivity and reducing manual inbox management.

This example email scenario uses AI to triage incoming emails, escalate those that need agent intervention, and respond automatically to others.

Click here to download the AI email handling example scenario, then import it into your contact center.

Prerequisites

  • Configure email services for inbound and outbound email.

    • Set up a separate service for each category of email you expect the AI to distinguish between, plus one to use by default. This allows the scenario to route complex cases to the relevant teams.

  • Do one of the following:

    • Have your service provider configure an AI account as part of the selected AI Package assigned to your contact center.

    • Configure an AI provider integration account in your contact center.


Take care when determining what latitude you give AI to respond on your company's behalf. Depending on your use case, it may be advisable to give human oversight to AI response emails, or to only use AI for certain cases. Refer to your company's AI policies before implementing any AI tools.



Scenario Flow

Screenshot of an AI email handling scenario

Ask AI to categorize the email, determine whether it needs escalation, and extract relevant data. AI then drafts an automated reply email based on that categorization. Finally, the scenario either sends the email draft or escalates to a human agent. In the event of an escalation, the contents of the email draft are added to the case as a suggested reply.

Categorize the Email

Add an Ask AI scenario block to analyze the email with the goals of categorization, data extraction, and evaluation.

  1. Select the desired AI provider from the AI Provider drop-down menu.

  2. In the Instructions to AI field, prompt the A to read the email and prepare it to do a number of tasks. An example prompt is provided below:

    Here's the body of an email thread potentially containing multiple back and forth messages: $(item.body)
    
    Read the whole email thread and then do the following:
    
    1. Categorize this email into one of the listed categories, selecting only values from among the provided options:  
    	- Information request  
    	- Order status request  
    	- Other
    
    2. If the customer is asking a general question:
    	a. Identify the question that the customer is asking.
    	b. Extract relevant search terms from the email.
    
    3. If an order ID is mentioned, extract it from the email.
    
    4. Decide if this email needs to be escalated to a human agent based on the criteria:
    	- Does it involve high-stakes?
    	- Is the situation complex?
    	- Does the email contain emotionally charged issues, such as severe complaints, VIP client requests, or complex troubleshooting requiring empathy?
    	- Is the category "other"?
    
    5. Extract the customer's name from the email body (such as their signoff or signature). Otherwise, our CRM shows their full name as $(item.firstName) $(item.lastName).
    
    6. Detect what language the email is in.

  3. The example instructions ask the AI to provide several data points from the provided email: the category, whether the customer is asking a question, an order ID if it exists, etc. For each data point, add a corresponding variable to the Data to extract section. Be precise and descriptive when defining variables, as this information is provided to the AI prompt.

    1. Press add Output Data.

    2. Add a variable named category. Describe it in basic terms in the Data description field. For Example values, list exactly the same categories as in the Instructions to AI field to ensure predictable results.

      Screenshot of the Add Output Data modal of an Ask AI scenario block

    3. Press the green checkmark icon to save.

    4. Configure the remaining data to extract as follows:

      • escalate:

        • Data description: If the email needs to be escalated to a human agent.

        • Example values: true, false

      • customer_name:

        • Data description: Customer's name.

        • Example value: John Doe

      • language:

        • Data description: Language used in the email.

        • Example values: English, German

      • customer_question:

        • Data description: Identify the question being asked in the email.

        • Example value: How do I recover my password?

      • question_search_terms:

        • Data description: If the customer has a question, extract a few search terms to query the knowledge base.

        • Example values: activate warranty, create new user

      • order_no:

        • Data description: Order ID number.

        • Example value: 001000



Add Branching Paths for Each Category

The $(category) variable should now be populated by the AI. Use an If block to set different paths for each expected value, plus a path to follow in the event that no category was set. Depending on the category assigned by the AI, the scenario will assign a different service and draft a tailored reply email. Configure each path as follows.


Order Status

If $(category) is set to order_status_request, the scenario will try to retrieve the order information from a database using the extracted $(order_no) and prompt the AI to compose a response email.

  1. In the If block, press the Add branch button.

  2. Name the branch via the Exit label field. In this example, we use the name Order Status.

  3. Click Add condition.

  4. Configure the fields such that they read Scenario variable (string) category is = order_status_request. Then, click the green checkmark.

    Screenshot of the Add Condition modal of an If scenario block. The selected fields read Scenario variable (string) category is = order_status_request
  5. Within this branch, use a Set Service block to select the Orders service.

  6. In this example, we have a database containing a table of orders. As such, we can use a DB Execute block to query that database for the provided order number.
    Note: In practice, we recommend checking that $(order_no) contains a non-null well-formed value before using it in a database query.

    Screenshot of a DB Execute scenario block that connects to the All orders database. SQL statement reads SELECT * FROM orders WHERE id=$(order_no). Recordset name is orders.
  7. Use an Ask AI block to draft a reply email with the customer's order information. An example prompt is provided below:

    Reference the customer's order information: $(order)
    
    As a support agent, draft an email reply (in $(language)) updating the customer on the status of their order, including delivery information if available.
    
    Only use information from the provided source. If no status or delivery information is available, draft an email requesting additional information.
    
    Begin your response with "Dear $(customer_name), \n".

  8. Configure the data to extract as follows:

    • reply:

      • Data description: Automated reply email.

General Question

If the $(category) variable is set to information_request, the scenario will prompt the AI to answer the customer's question using knowledge base information.

  1. Add a General Question branch to the If block with the condition Scenario variable (string) category is = information_request. See steps 1-4 of Order Status above.

  2. Within this branch, use a Set Service block to select the Knowledge Base service.

  3. Using a Fetch URL block, make an API call to search your external knowledge base for $(question_search_terms).
    Note: In this example, jsdata is the scenario variable prefix for the returned JSON data.

  4. Use an Ask AI block to parse the knowledge base search results and compose a response. An example prompt is provided below.

    Reference the knowledge base information at $(jsdata) to find the answer to the following question: $(customer_question)
    
    As a support agent, draft the answer (in $(language)) to the customer's question. Begin your response with "Dear $(customer_name), \n".
    
    Only use information from the provided source. If the answer is not in the provided source, the email needs to be escalated to a human agent.
  5. Configure the data to extract as follows:

    • reply:

      • Data description: Automated reply email.

    • escalate_question:

      • Data description: If the question needs to be escalated to a human agent.

      • Example values: true, false

Other

If the $(category) variable is other or empty (i.e. the AI fails to select a category), the scenario will escalate to a human agent assigned to the Default service.

  1. Add an Other branch to the If block with two conditions: Scenario variable (string) category is Is empty or Scenario variable (string) category is = other. See steps 1-4 of Order Status above.

  2. Within this branch, use a Set Service block to select the Default email service.

  3. Use a Find Agent block to route the customer email to an agent assigned to the Default service.

  4. Exit the scenario.

Auto-Reply or Escalate

The $(escalate) variable should now be populated, indicating whether to involve an agent or send the auto-reply. Depending on the path taken earlier in the scenario, the $(escalate_knowledge) variable may be populated as well. Use an If block to check the value of these two variables. If neither indicates that escalation is needed, the scenario will send the auto-reply email drafted in the previous step to the customer, then terminate. In all other cases, the scenario will save the auto-reply draft to the case notes and assign the customer email to an agent. Following this logic creates a bias toward escalation and prevents the AI from handling ambiguous cases without human input.

Auto-Reply

If $(escalate) is false and $(escalate_question) is either false or empty (i.e. is not set), the scenario will take this path.

  1. Add one branch to the If block with two blocks of conditions. See steps 1-4 of Order Status above for more information on adding conditions.

    A screenshot of two blocks of conditions for an If scenario block exit.
    • Add the following block of conditions to check whether the AI initially marked the customer email as in need of escalation:
      Scenario variable (string) escalate is = false or Scenario variable (number) escalate is = 0 or Scenario variable (string) escalate is = 0.

    • Add the following block of conditions to check whether the AI marked the email as in need of escalation later in the scenario:
      Scenario variable (string) escalate_question is = false or Scenario variable (number) escalate_question is = 0 or Scenario variable (string) escalate_question is = 0 or Scenario variable (string) escalate_question is Is empty.
      Note: If $(escalate_question) is false or 0, that indicates the scenario followed the General Question path and successfully found an answer to the customer's question. If $(escalate_question) is empty, that indicates the scenario followed a different path.

    • Join these two blocks with an and operator to check that both variables indicate no need for escalation.

  2. Within this branch, use an EMail block to send the auto-reply composed by the AI to the customer.
    Screenshot of an EMail scenario block

    • In the From section, enter your contact center's display name and outgoing email address.

    • In the To section, set the destination email address to $(item.from).

    • In the Message section, enter the email's subject as RE: $(item.subject). Select HTML format.

    • In the editor, add $(reply), a new line, and (in block quotes) $(item.body) to display the AI reply email above all previous emails in the thread.

    • Optional: Press the Test Send button to send a test email to a recipient of your choice.

  3. Use an Item Completed block to set the disposition to Auto-reply.

  4. Exit the scenario.

Escalate to Human Agent

If at any point the AI set $(escalate) or $(escalate_question) to a value other than false or 0, the scenario will skip this If block entirely and escalate the email to a human agent.

  1. Use a Set Case block to associate this interaction with the case in your Bright Pattern contact center.
    Screenshot of a Set Case scenario block with Case ID set to $(item.caseId) and the Replace checkbox enabled.

  2. Use a Bright Pattern Create Object block to add the AI-generated reply to the case's activity history for reference by human agents.

    Screenshot of a Bright Pattern Create Object scenario block that creates an Activity history object. Notes read "Suggested answer (AI-generated): $(reply)"
  3. Use a Find Agent block to route the customer email to an agent assigned to the selected service.

  4. Exit the scenario.

Final Steps

  1. Save the scenario with a new name. Closing the browser tab or window before saving will delete your work.

  2. Create a scenario entry linking this scenario to an email service.

  3. Send that service test emails in a variety of languages and formats to verify that all paths in this scenario work as intended. Include the following test cases:

    • General questions with answers in your knowledge base

    • Questions that you judge to need a human agent's assistance

    • Well-formed order status requests

    • Ill-formed or vague order status requests

    • Other customer issues not covered by this scenario

      < Previous | Next >