This is a WordPress plugin which adds an AI chatbot to your website. The AI chatbot uses Retrieval Augmented Generation (RAG) to fetch the contents of your website and respond based on it, which means users can ask the assistant anything about the contents of your website and the chatbot will be able to answer them.
-
Clone the repository and move into it.
git clone https://github.com/ZenithFlux/wordpress-ai-assistant.git cd wordpress-ai-assistant
-
Install the required dependencies.
pip install -r requirements.txt
-
Set all the environment variables mentioned in
.env.template
file. You can also rename it to.env
and put the values in it.An important variable here is
AUTH_KEY=<Backend-API-Key>
. This key will be needed whenever we want to communicate with the backend. -
Run the Flask server.
flask run
The backend will run at the URL http://127.0.0.1:5000
. For rest of the README, we will assume this to be the URL of the Python backend.
Note: If your backend server is running at a different URL, change the value of the static variable $ASSISTANT_URL
accordingly in the wordpress_plugin/wordpress-site-assistant/wordpress-site-assistant.php
file.
First, to use the Assistant on your website, you must build a database of the contents of your website. Assistant will use this data to generate responses specific to your site. Your website must be a WordPress site.
To do this, send a POST request to http://127.0.0.1:5000/db
with the following structure:
Authorization: Bearer <Backend-API-Key>
Content-Type: application/json
{
"site_url": "https://www.yoursite.com",
"create_if_not_present": true
}
You can use a tool like Postman or cURL for this.
The server will automatically create a database for yoursite.com. After this, you will be able to use the AI Assistant on this site.
- Copy the
wordpress_plugin/wordpress-site-assistant
directory into thewp-content/plugins
folder of your WordPress website. - Add the following line to your
wp-config.php
file or wherever you store the secrets for your WordPress site.define( 'WORDPRESS_SITE_ASSISTANT_API_KEY', '<Backend-API-Key>' );
- Open your WordPress Dashboard > Click on Plugins > Activate the Wordpress Site Assistant plugin.
- Go to your Pages list. You will see that a Wordpress Site Assistant page has appeared there. This is where your users can chat with the AI Assistant.
Congratulations, you have now successfully added the WordPress Site Assistant to your website.