The POC (Proof of Concept) aims to showcase an example of a customer service chatbot by integrating two open-source projects via API and webhooks.
-
Danswer: An open-source RAG (Retrieval-Augmented Generation) system that allows users to set up connectors to different sources and load data into a vector database. It uses advanced RAG techniques to retrieve relevant information based on a user's query and sends it to an LLM (Large Language Model) to generate an answer.
-
Chatwoot: An open-source live chat solution that powers customer support for websites. It displays a chat window on the website where visitors can interact with customer support. Additionally, it offers a back-office platform to manage tickets created by users and allows agents to conduct discussions.
This POC aims to use Danswer as an AI agent for Chatwoot. The flow is that users joining the chat are redirected to the AI agent in Danswer.
- They can ask generic questions about the website.
- Or they can inquire about finding products (e.g., in an e-commerce setting).
-
Configure a Danswer Instance and a Persona:
- A persona in Danswer has a prompt and a set of documents it has access to.
- For instance, you can have a single Danswer instance with multiple scraped websites, and then create a persona for each website with access only to relevant documents/web pages for that website.
-
Load the Website in Danswer:
- Loading data is simplified using the web connector and its recursive feature. Custom connectors might be needed to better clean up documents.
- However, for the purpose of this POC, the generic web connector suffices.
-
Configure an Agent Bot on Chatwoot:
- You can refer to these links for configuring and understanding the message types that can be sent to Chatwoot (e.g., cards, simple messages, select boxes):
-
Parameters Configuration in This Repository:
- Update the
login_dataincreds.pywith your own credentials to connect to your Danswer instance. chatwoot_bot_token: Token generated when adding the bot in the Chatwoot interface.chatwoot_url, danswer_url: URLs of the servers hosting the Chatwoot and Danswer apps (In this example, both were running on a single VM with 16GB RAM, 4 CPU cores, using Docker Compose).- Using the inspection tool in the Danswer web app, you can find the
persona_idand theprompt_idcreated for the specific persona. You need to input these indanswer.py(check the API call tosend-message).
- Update the
-
Tweak the Persona:
- In this POC, the LLM is prompted to detect the intent of the conversation to handle three scenarios:
- Recommendation: When the user asks for a product recommendation, this triggers a search request on the vector database to retrieve relevant products (documents).
- Generic: The LLM replies with general knowledge without document search.
- Agent: Chatwoot allows switching the ticket between the bot and a human agent. If the LLM detects a request for human assistance, it disconnects and switches the ticket status to
pending.
- In this POC, the LLM is prompted to detect the intent of the conversation to handle three scenarios:
Note: Ensure the persona prompt specifies the output message format, as it should include these patterns for parsing in parse_response_text to work correctly:
response_pattern = r"<Response>([\s\S]*?)</Response>"
intent_pattern = r"<Intent>([\s\S]*?)</Intent>"
suggestions_pattern = r"<Suggestions>\[([\s\S]*?)\]</Suggestions>"