Make AI answer the questions using the context from your website

Chatting with AI is possible via the OpenAI Integration using this approach: Complete chat with OpenAI but how do you provide the scope of the conversation so that the user is chatting with your website, instead of the general knowledge?

This use case can be implemented by providing the AI model additional context when asking it to complete the chat. OpenAI provides a way to add such context using assistants. Assistant-based chat completion allows using tools including retrieval, so if an assistant has needed content uploaded, it takes it into account automatically. Here are the steps to take to implement this approach.

Step 1. Create and set up an OpenAI integration, as described here.

Step 2. Create an assistant at OpenAI here.

Add the needed instructions for the chat completion.

You can upload additional files that you’d like the assistant to consider when performing the completion. Manual uploading is good for the use cases when the information doesn’t change frequently or is private and there’s no web access to it.

If the website or knowledge base is accessible, you can automate scraping its content and uploading it to the selected Assistant using OpenAI integration’s Automation settings:

Screenshot2024-03-07at15.48.11.png

Click to create an automation rule:

3ac8b1eb-5fa3-44fb-b146-99d11644fd8d.png

Set its parameters including:

  • the website URL that needs to be scrapped
  • additional parameters for the scraping
  • target OpenAI assistant where the result will be uploaded
  • format of the result file(s)

Click to save the integration. Eventually, the website will be scraped and the result will be uploaded to the selected OpenAI Assistant.

Step 3. Add bot variable of type Chat Completion:

Screenshot2024-03-07at15.03.43.png

Set the initial and follow-up parameters:

{
    "thread": {
        "messages": [
            {
                "role": "user",
                "content": "{{chat_prompt}}"
            }
        ]
    }
}
{
    "thread": {
        "messages": [
            {
                "role": "user",
                "content": "{{chat_prompt}}"
            }
        ]
    }
}

This variable will create a response from a bot based on the user input, which is represented by the chat_prompt variable.

Step 4. Add a step for the user input:

Note that the code name for this step is chat_prompt - this automatically creates a bot variable with the same name.

Step 5. Add a step response with the chat completion:

Screenshot2024-03-07at15.56.58.png

This response uses the completed_chat_assistant variable created in Step 3.

Edit this page

Categories
Tags
See also