=== Talk To Website ===
Contributors: @talktowebsite
Donate link:
Tags: AI, ChatBot, ChatGPT, Assistant
Requires at least: 6.2
Tested up to: 6.7
Stable tag: 1.0
Requires PHP: 8.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

AI chatbot powered by ChatGPT from OpenAI. Scans the content of your site, then trains an AI assistant that speaks to users like a live person.

== Description ==

This plugin is an AI chatbot that integrates with ChatGPT via API by OpenAI. After installation and customization, a chat bubble will appear on your website. The plugin will talk to your website visitors like a live person, motivating visitors to take certain actions. This is something like a sales manager, who will help users navigate the site and advise on your products and services.

Our plugin is based on the most advanced AI models from OpenAI. We use the ChatGPT-4o model. Please note that for correct work you need a working account on OpenAI platform site and some funds on your balance.

The plugin has flexible customization, and allows you to define very precisely how it should communicate with your site visitors. You can ask the AI to motivate users to make purchases, visit certain pages, or perform other actions. The AI assistant will try to guide users exactly in such a way that they are maximally active on your site.

The plugin will prompt users with links to various pages on your site. If you sell products through your site, a visitor will be able to ask the plugin to find products based on a given set of criteria. As a response, the AI will be able to return a direct link to specific pages on the site. In other words, you can also think of the plugin as a super-smart search engine for your site that will help the visitor not only find the information they need, but also take the necessary actions on your site.

= Plugin Features: =

* Communication with visitors in human language ( any languages supported by OpenAI )
* Accurate answers based on information from your website
* Direct links to pages on your site as answers to questions
* Customizable nature of communication. Several unique characters-consultants.
* Customizable limits and precise control over API usage
* Detailed logging of dialogs with users
* Customizable level of humor. A robot that can joke!
* Custom instructions on how to communicate with users
* Flexible system of training and re-training of AI assistant

== Frequently Asked Questions ==

= Why might I need your plugin? =

Our plugin helps turn your website into a live consultant. The AI assistant will learn articles from your site, and speak to visitors in human language. After installation and customization, a chat bubble will appear on all pages of your site. Inside the chat bubble, the visitor will be able to talk to your site like a human being.

= Which AI model your plugin is based on? =

Our plugin is powered by ChatGPT from OpenAI. We use the most modern ChatGPT -4o model. For correct work of the plugin you will need a personal account on the OpenAI platform website with a positive balance.

= Do I have to pay to use the API from OpenAI? =

Yes. Since the plugin is powered by OpenAI's API, you need a positive balance on their site. The cost of using their API will directly depend on the number of dialogs with users, and the amount of content on your site that will be used to train the AI.

= Will I be able to see what visitors have been talking about with the plugin? =

Yes, there is a “Dialogs” section inside the plugin. Inside it you will see a list of all dialogs between site visitors and AI assistant.

= Can I influence the costs associated with the use of APIs? =

Yes, the plugin allows you to flexibly set limits on dialog length and context window length. You can define a maximum daily spending level that will not be exceeded.

= Can I pre-educate the plugin additionally ( except for materials from the site )? =

Yes, you can give the plugin as many additional instructions as you want. There is a special field with arbitrary text for this purpose.

= Can I prevent the plugin from talking about any topics? =

Yes, you can specify in a special text field a list of topics, communication on which the plugin should avoid. The robot will refuse to communicate with users on these topics.

== Installation ==

* Install Talk To Website either via the WordPress.org plugin repository or by uploading the files to your server. [See instructions on how to install a WordPress plugin](https://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/)
* Activate Talk To Website.
* Navigate to the Talk To Website tab at the bottom of your admin menu and click the “Settings + Chat” row to begin creating your AI assistant.
* Click on the “Settings” tab inside the plugin. Make sure you see the “Your OpenAI API key” input.
* Go to the [OpenAI platform](https://platform.openai.com/), create a new account or use an existing account.
* Refill your balance on the [OpenAI platform](https://platform.openai.com/settings/organization/billing/overview) for a few dollars.
* Go to the [API keys](https://platform.openai.com/api-keys) section and create a new API key.
* Copy the newly created API key into the plugin settings, in the “Your OpenAI API key” field. Press on the “Test and save API key” button.
* Check and save the plugin settings using the “Save all settings” button.
* Click on the “Training” tab. Select articles from the website based on which you want to train AI. Use the checkboxes to make your selections. Click the “Train AI” button.
* Your plugin is fully customized and ready to communicate with site visitors on behalf of your company.

== External services ==

For its operation, our plugin uses the API from the OpenAI platform. This is vital for our plugin to work because our plugin uses ChatGPT to train the AI assistant and then communicate with users. We pass a minimum of necessary information through the API. We call the following API methods for the following needs:

* https://api.openai.com/v1/chat/completions (POST) - the call is used to test the plugin by validating your API key and initially saving the settings. Usually this call is made at the moment of initial plugin configuration, when you specify your API key. As part of this call, we send your API key as well as a set of test messages, such as “Say this is a test!”.
* https://api.openai.com/v1/files (POST) - the call is used to upload a training file with a list of articles from your site, as well as links to the pages of your file. This file has JSON format. The content of the file is created on the basis of the pages that you decided to use for training the AI assistant when working with the “Training” tab. The file contains the texts of articles from the pages of your site, as well as links to the corresponding pages of your site. A copy of this file is stored on your site, in the plugins/talk-to-website/admin/training directory.  As part of this call, we send the file itself, as well as your API key. This function is called when you perform plugin training on the “Training” tab. We only send information about the articles that you have specified in the training process using the checkboxes.
* https://api.openai.com/v1/files/file_id (DELETE) - the call is used to delete an old file that was used in past AI training. As part of this call, we send the ID of the file to be deleted in the file_id parameter, as well as your API key. This function is called when you perform training of the plugin on the “Training” tab, in case we found old files used for past training.
* https://api.openai.com/v1/vector_stores (POST) - the call is used when training the plugin, after loading a file using the v1/files method. After uploading a training file, we create a vector store where we put the newly uploaded file. Accordingly, this happens only when training the plugin in the “Training” tab. Within this call, we send the ID of the created file, the name of the vector storage, as well as your API key.
* https://api.openai.com/v1/vector_stores/store_id (DELETE) - the call is used to delete the old vector store that was created during the past AI training. This only happens when training the plugin in the “Training” tab. As part of this call, we send the storage ID in the store_id parameter, as well as your API key.
* https://api.openai.com/v1/assistants (POST) - the call is used when training the plugin, after creating a vector storage using method v1/vector_stores. Also, this call is used when changing the parameters of the AI assistant (e.g. robot name, additional instructions, company contact phone number, company address, prohibited topics for conversation, and so on - text fields from the “settings” tab inside the plugin). As a result of this call, an AI assistant is created on the OpenAI platform, trained according to the specified settings, and associated with a training file with a list of materials from your site. As part of this call, we pass your API key, as well as various textual information from the “Settings” tab: type of GPT model, robot name, instructions on the robot's character, general textual instructions for training, forbidden topics and words, humor level, language used to communicate with visitors, contact information about your project (Email, phone number, website address, map address), limits on the length of responses, your website address, a brief description of your website, the ID of the associated vector store.
* https://api.openai.com/v1/assistants/assistant_id (DELETE) - the call is used to delete old AI assistants on the OpenAI platform that are no longer needed. As part of this call, we send the assistant ID in the assistant_id parameter, as well as your API key.
* https://api.openai.com/v1/threads (POST) - the call is used to create a new conversation thread with the AI assistant. It is used when starting a new dialog between a site visitor and the AI assistant. As part of this call, we send your API key.
* https://api.openai.com/v1/threads/thread_id/messages (POST) - the call is used to create a new message from the user to the AI. It is used each time a message is sent to the chat room from the user. The “thread_id” parameter in the URL is the identifier of the thread that was created using the v1/threads call. Within this call, we pass the thread id as well as the text of the message entered by the user in the chat window. Also within this call, we pass your API key.
* https://api.openai.com/v1/threads/thread_id/messages (GET) - the call is used to get a list of messages that were sent to the AI or received as a reply from the AI. It is used every time when sending messages to the chat from the user, as well as when receiving a list of responses from the AI. The “thread_id” parameter in the URL is the identifier of the thread that was created using the v1/threads call. Within this call we also pass your API key.
* https://api.openai.com/v1/threads/thread_id/runs (POST) - the call is used to create a run within the AI thread. In other words, causes the AI assistant to analyze the messages sent, and generate responses to those messages. It is used every time chat messages are sent from a user. The “thread_id” parameter in the URL is the identifier of the thread that was created by the v1/threads call. Also, within this call we pass your API key, and also some service information ( context depth, run temperature ).
* https://api.openai.com/v1/threads/thread_id/runs/run_id (GET) - the call is used to get the status of the run ( to understand that the run is complete and we can see the results of the run ).  The “thread_id” parameter in the URL is the identifier of the thread that was created using the v1/threads call. The run_id parameter is the id of the run that was created using the /v1/thread_id/runs (POST) call.  Also, as part of this call we pass your API key.
* https://api.openai.com/v1/models (GET) - the call is used to retrieve a list of AI models that are available for your account. This is a rare and optional call that is practically not used by the plugin. Also, within this call we pass your API key.

More information about the OpenAI platform: [homepage](https://platform.openai.com/), [tems and policies](https://openai.com/policies/), [terms of use](https://openai.com/policies/terms-of-use/), [privacy policy](https://openai.com/policies/privacy-policy/).

== Screenshots ==

1. Online chat between the user and the website
2. Main page of the plugin
3. AI chat personality settings
4. Chat bubble appearance settings for public pages of the site
5. Plugin Training. Selection of materials for AI assistant training
6. Details of dialogs between users and the AI chatbot

== Changelog ==

= 1.0 =
* The very first, stable version of the plugin
* Automatic creation of an AI assistant and its training based on site materials
* Ability to flexibly customize the AI assistant through the Settings section