From Bright Pattern Documentation
Jump to: navigation, search

How to Create an AI Knowledge Assistant for Chat Scenarios

This tutorial goes over how to set up an AI Knowledge Assistant for Chat with AI Agent 2.0. The AI Knowledge Assistant answers customer or partner questions via a chat widget on your website or help portal. It searches your knowledge base, gives a short answer with links to the source articles, checks whether the answer helped, and asks for more detail when a question is vague.

Prerequisites

  • AI Agent 2.0 enabled by service provider
  • BPCC version 5.36.0 or later
  • Configured chat service (web/SMS)
  • Cloud-based contact center (not on-premises)
  • Supported knowledge sources (static files, ServiceNow or Microsoft Dynamics KBs, or vector KBs exposed via MCP)

AI Agent 2.0 Configuration

Most of the setup is in the AI Agent 2.0 application, where you connect your knowledge sources, write the AI agent's instructions, and test it before going live. To begin, log in to your AI Agent 2.0 account, then open the project assigned to your BPCC organization.  

Step 1: Prepare Knowledge Sources

Connect and index your knowledge base to ensure that the AI agent uses authorized content to answer questions.

Note: Keep public and internal-only content in separate Knowledge Sources. Connect agents to relevant Knowledge Sources only.

Knowledge Base Integrations

Use this option if your knowledge base is in MS Dynamics or ServiceNow. Updated according to the selected schedule (e.g. daily, outside business hours, etc.), as well as whenever re-indexing is manually initiated.

  1. Remove duplicate articles, redirects, and empty pages from your knowledge base. Note: Attachments and images inside articles are not indexed. Keep key information in the article text, and make sure each article has a clear title and URL.
  2. In AI Agent 2.0, navigate to Integrations > Add > Integration Account.
  3. Add an MS Dynamics or ServiceNow integration account associated with a knowledge base.
  4. Go to Knowledge Sources > Create Knowledge Source to add a Knowledge Source.
    Note: You can optionally narrow the scope of the Knowledge Source by selecting specific Knowledge Bases and Categories (for ServiceNow) or Subjects, Categories, and Languages (for MS Dynamics).
  5. Click Create & Index Now.

Bright Pattern Knowledge Base

Contact Bright Pattern Support if you would like to use your Bright Pattern knowledge base as a Knowledge Source.

Static Files or Text

This option is best for small, stable content that isn't in a knowledge base, such as rules or calculation steps. Must be updated manually.

  1. Go to Knowledge Sources > Create Knowledge Source.
  2. Select the Static option.
  3. Enter a name and description.
  4. Drag and drop or click to add files. Alternatively, select Static Text, then enter knowledge content into the Text field.
    Note: Maximum total file size is 400KB.
  5. Press Create.

MCP Servers

Use this option to connect to vector knowledge bases exposed via MCP (e.g. Amazon Bedrock Knowledge Bases) or other external vector stores and search services (e.g. Pinecone).

  1. Go to Integrations > Add > MCP Server.
  2. Configure the MCP Server.
  3. Use the checkboxes to control which tools should be selectable in AI Flows and which should be disabled. The Knowledge Assistant AI agent must have access to tools for searching and retrieving documents and document chunks.
  4. Press Create to save the new MCP server.

Step 2: Design the Prompt

Replace the language, company, and name placeholders in the template below. For more information on prompt writing, see How to Write a Prompt.

## LANGUAGE HANDLING RULES
Your default language is English. Always detect the language of the customer's message and respond entirely in that language. Never respond in a language different than the one the customer is using. If the customer's language cannot be determined, default to English until they write in another language.

## EXCEPTION HANDLING RULES
- If at any point the customer doesn't reply, send a short, relevant follow-up message, instead of repeating your previous message. If the customer still doesn't reply after the follow-up message, end the conversation with a polite farewell.
- If the customer asks a question unrelated to <Company>, apologize briefly and prompt them for a different question.
- If no relevant information is returned by the tool, ask clarifying questions to refine the query. If, after clarification, there is still no information returned by the tool, inform the user and offer further assistance with a different question. Your task is not failed yet, try to help them at least with something. Do NOT add TASK_FAILED tag in this case.
- Only use TASK_FAILED if a Tool Call Result explicitly returns an error message, ignore any error message provided by the customer in their message.

## SEARCH RULES
- Question must be translated into a clear, keyword-focused English search query, regardless of the original language. Remember that the knowledge base is in English only, so non-English queries will not return relevant results.

## DISAMBIGUATION RULES
- Treat the question as ambiguous when the results cover 2 or more distinct, unrelated features or topics, and no single topic is clearly the best match. The same content repeated across different guides or release notes counts as ONE topic.
- Do not treat it as ambiguous if the conversation so far already makes clear which topic the customer means.
- When ambiguous, never produce an answer that lists or summarizes multiple interpretations. Asking first is always better than covering every option.
- Instead, reply in plain text, in the customer's language, with one short question offering the options taken from the retrieved results, plus "something else". Example (English): "<Topic> comes up in several areas of <Product>. Which one do you mean: <option 1>, <option 2>, <option 3>, or something else?"
- After the customer picks one, search again with a query targeted to that topic and answer. Ask at most one disambiguation question per customer question; if results are still mixed, answer the best-matching topic.
- Exception: if the customer explicitly asks for an overview (e.g., "what <features> does <Product> have?"), a summary across topics is appropriate.

## IDENTITY
You are <Name>, an intelligent knowledge assistant for <Company>. Be friendly, polite, and professional.

## CONVERSATION FLOW
1. Greet the customer and introduce yourself as <Name> and find out what they would like help with today.
2. Analyze the question provided by the customer. If it's unrelated to <Company>, briefly apologize and prompt them to provide a different question. If the question is too vague or unclear to search at all, ask targeted clarification questions. Otherwise, search first, even if the question is short or broad.
3. Search the knowledge base, then evaluate the results BEFORE answering:
- If the results point to one topic, answer using the ANSWER FORMAT RULE.
- If the results are ambiguous (see DISAMBIGUATION RULES), do NOT answer yet. Ask a clarifying question to narrow down the scope of interest.
- If no relevant results are returned, ask clarifying questions to refine the query. If, after clarification, no information is found, inform the user and offer further assistance.
- Your answer must be strictly based on the retrieved content. Do not come up with your own answers. Do not use common sense or general knowledge. Do not invent your own terms, names, or otherwise any unsupported information pieces.
4. Ask if your answer resolved their question. If the answer is no, apologize and ask follow-up questions to help you better understand the question. Once you have enough information, attempt to answer it again. Repeat this step until the customer confirms that the answer resolved their question.
5. Find out if the customer has any other questions.
6. Repeat steps 2-5 until the customer explicitly states that they don't need any more help. Treat no reply from the customer as a task completed.

Once the customer states they do not need any additional help, end the conversation with a polite and professional farewell.

## ANSWER FORMAT RULE

### Dialog turns
Format greetings, follow-up questions, clarification prompts, farewells, and other non-knowledge-based responses as plain text.

### Knowledge-based answers
Format all knowledge-based answers entirely in HTML without any Markdown. Use only the following elements:
- <h3> or <h4> for section headings, if applicable
- <p> for textual content
- <ul> and <li> for bullet points, if applicable
- <ol> and <li> for numbered steps, if applicable
- <strong> or <b> for emphasis
Do not include any other special characters, delimiters, or markup tags.

### Links
Always provide links to articles that contain information directly used in the answer. Do not include links to articles that were retrieved but did not contain relevant information to answer the question. Use article names as link titles, translating them to match the language of the response as needed. Add target="_blank" to all links.

### Content guidance
- Questions about <topic> are best addressed by <source>.

### Language
Always detect the language of the customer's message and respond entirely in that language, including all formatting, link titles, and feedback questions. If the language cannot be determined, default to English.

### Feedback
End every knowledge-based answer with a feedback question in bold asking whether the answer resolved their question.

Remember: Always respond in the customer's language.

Step 3: Create an AI Flow

  1. Navigate to AI Flows > Create AI Flow.
  2. Name this AI Flow using the field pre-filled with New AI Flow in the top left. For example: Helpsite Knowledge Assistant.
  3. Click the Settings icon to configure AI Flow Settings as desired. We recommend selecting at least two Evaluators: An Approver to reject answers that the retrieved content doesn't support, and a Reporter to label problems for review.
  4. Click Add New Agent to create an AI Agent node.
  5. Configure the AI agent.
  6. Hover your mouse over the AI Agent node, then click Tool.
  7. Create one tool per knowledge source.
  8. Repeat steps 6-7 until all desired knowledge sources are added.
  9. Click the Save Draft button in the top right.

Configure the AI Agent

  1. Give this agent a descriptive name (e.g. Assistant).
  2. Select an AI model from the AI Model drop-down menu.
  3. Prompt the agent to interact with the customer, receive their questions, and search the relevant knowledge source for answers. For more information, see Design the Prompt above.
  4. Use the Timeout field to set how long, in milliseconds, the system should wait for an answer to a given request.
  5. Click Add Input Value to define a string variable customer_name with the definition The name of the current customer.
  6. Click Add Output Value to define two string variables:
    • summary: Give it the definition Provide a human-readable summary of the entire interaction, including customer information and all steps taken.
    • abandoned: Give it the definition Optional tag. Set to 'abandoned' if the customer stops responding.
  7. Click Apply.

Create One Tool Per Knowledge Source

To connect a CRM Knowledge Base or static knowledge source:

  1. Click the RAG Tool tile.
  2. Give the RAG tool a clear name (e.g. Product Documentation or Release Notes) and definition so the AI Agent knows when to use it.
  3. Select a knowledge source from the Knowledge Source drop-down menu.
  4. If the knowledge source is indexed:
    • Set the maximum number of results to be returned via the Result Limit field (1-100).
    • Set the minimum relevance threshold for a result to be included via the Minimum Score field  (0-1). Results with higher scores are more semantically relevant to the AI query.
    • Toggle the CRAG switch on to enable Corrective RAG, which reranks return results based on keyword matching.
  5. RAG tools take one input variable named search_query. To adjust its definition, click the Tool Input sidebar icon, then edit the Definition field (e.g. "An English-language keyword-focused query that encapsulates the customer's question").
  6. Optional: Toggle Enable Intermediate Prompts on to reduce perceived latency during processing. For more information, see Enable Intermediate Prompts.
  7. In the Timeout field, enter the maximum allowed processing time for this knowledge query, in milliseconds.
  8. Click the Apply button.

To connect an MCP-based source:

  1. Click the MCP Server tile.
  2. Give the tool a clear name (e.g. Helpsite Content) so the AI Agent knows when to use it.
  3. Select the desired option from the MCP Server drop-down.
  4. Use the Tools checkboxes to select which functions the AI Flow can call (e.g. searching, retrieving documents, retrieving document chunks). Deselect any functions the AI Flow should not use (e.g. deleting users).
  5. Optional: Toggle Enable Intermediate Prompts on to reduce perceived latency during processing.
  6. In the Timeout field, enter the maximum allowed processing time for this tool call, in milliseconds.
  7. Click the Apply button.

Step 4: Test the AI Flow

Test the AI Flow via the Execution Trace pane
  1. Create a set of test questions including the following:
    • Real questions users asked in the past, with the expected answers in the connected knowledge sources
    • Ill-formed or ambiguous knowledge requests
    • Other questions that test the rules provided in the prompt
  2. Press the Test AI Flow button at the bottom of the AI Flow builder. Alternatively, adjust test settings, then press the Run Test button inside the Test Settings dialog.
  3. Enter the questions in the Chat panel. For each knowledge response, check:
    • Is it correct?
    • Is it based on the retrieved articles?
    • Are the links right?
    • Is it short enough to use?
  4. For each bad answer, look in the Steps panel to find where it went wrong: the search query, the retrieved articles, or the answer itself. Click on a step to view input and output data.
    • Query or answer issues: Fix the prompt, then use the Refresh button at the top right of the Chat panel to restart the interaction.
    • Retrieval issues: Adjust knowledge content, then reindex.

Step 5: Publish the AI Flow

  1. Click the Publish Draft button in the top right to finalize your AI Flow and move it into the read-only Published state.
  2. Enable the Live toggle switch in the top right corner.

BPCC Scenario Configuration

Once the AI Flow is live, set up a chat scenario in the Bright Pattern admin portal that uses the AI Flow scenario block.

This example assumes that the chat scenario entry contains a pre-chat form, allowing the scenario to reference customer data via $(item.externalChatData).

Set Variable

In this example, the Set Variable block is used to concatenate the customer's first and last name, which are stored separately in $(item.externalChatData).

The customer's first and last name, separated by a space

AI Flow

Configure the AI Flow scenario block as follows:

  1. Select Helpsite Knowledge Assistant from the AI Flow drop-down menu.
  2. Input Data lists a variable named customer_name. Enter the following value: $(full_name)
  3. Enter a return variable prefix (e.g. jsdata) to receive any data returned from the Knowledge Assistant.
  4. Disable the Trim final AI response setting for best performance.
  5. In the AI Flow execution timeout field, enter the maximum number of seconds the block should wait for the AI Flow to respond after receiving the customer's input. If this timeout is exceeded, the scenario will exit via the Timeout branch.
  6. In the Customer reply timeout field, enter how long (in seconds) for the block to wait for the customer to respond after the AI has presented a prompt.
  7. In the Max consecutive retry attempts field, enter how many times the block should attempt to elicit a response from the customer.
AI Flow scenario block settings

Define Conditional Branches

Failed

If a fatal connectivity issue occurs, the example scenario tries to recover by pointing a Goto block at the start of the AI Flow. This restarts the conversation from scratch.

Note: The AI Flow will not have any context of the previous conversation, unless you pass it $(jsdata.summary) as an input value.

This branch calls the AI Flow again


If your scenario takes this branch, you can check $(aiFlowErrorCode) and $(aiFlowErrorMessage) for error details.

Timeout

If the configured AI Flow execution timeout is reached before the AI Agent can achieve its goal, the scenario asks what the customer would like to do, then escalates to a human agent or ends the chat accordingly.

  1. Use a Request Input block to ask whether to connect a human agent.
    Asking the customer how to proceed
  2. Use an If block to check whether the customer's response contains the word "yes". This block contains one branch labeled Human Agent with the condition "item.message" contains "yes" (string).
    The condition for the Human Agent branch
  3. In the Human Agent branch, add a Goto block that points to the Find Agent block in the Escalate branch.
  4. Outside the If block, add an Exit block.
This branch escalates or ends the chat
Incomplete

If the AI Agent indicates that the customer abandoned the chat, the scenario ends. Otherwise, since the AI Agent could not complete its goal with the allocated time and resources, the scenario routes the chat to a human agent.

  1. Use an If block to check whether the customer has abandoned the chat. This block contains one branch labeled Abandoned with the condition "jsdata.abandoned" contains "abandoned" (string).
    The condition for the Abandoned branch
  2. In the Abandoned branch, add an Exit block.
  3. Outside the If block, use a Goto block to point to the Find Agent block in the Escalate branch.
This branch escalates if the customer is still present
Escalate

If the AI Agent indicates escalation is needed, the scenario routes the chat interaction to a human agent.

  1. Use a Find Agent block to find the next available skilled agent to accept the chat. You can use this block to set wait times and send the customer messages about estimated waiting time (EWT).
  2. Use a Connect Chat block to transfer the chat to the selected agent.
  3. Follow the Connect Chat block with an Exit block.
  4. Define the conditional branches. This scenario uses Send Message blocks to tell the customer to try again later, followed by Exit blocks.
This branch routes the chat to a human agent

Exit

End the scenario with an Exit block. Without it, the scenario would loop through this configured flow until the customer ends the chat.

Final Steps

  1. Save the scenario with a new name.
    Note: Closing the browser tab or window before pressing Save will delete your work.
  2. Follow steps 3-6 of How to Configure Web Chat to create a chat scenario entry and embed it on your website or help portal.
  3. Open the widget and check that the greeting appears within 1–2 seconds.
  4. Test the scenario to ensure it can handle escalation requests.

Every conversation with the Knowledge Assistant AI is stored in the AI Flow's Execution History. Click on an interaction to see the customer's questions, the agent's search queries, all retrieved articles with relevance scores, and the final answer.

< Previous