How to Integrate ChatGPT into WordPress


Are you missing blog deadlines? Or are you tired of answering the same customer support questions over and over? Your content creation and engagement problems are hurting your site and profits.
Knowing how to integrate ChatGPT into WordPress would be promising. It can automate outlines and write SEO-optimized blog posts. Plus, it offers a smart chatbot for instant support, so you don’t need to hire more staff.
Top hosting providers are demonstrating how Site Owners can streamline content creation, add an AI chatbot, and enhance SEO workflows with ChatGPT integrations.
In this guide, you will be shown both plugin-based and manual methods to add ChatGPT to your site. By the end of this guide, you’ll have an AI partner. It will help boost your production, engagement, and weekly hours!
Why Integrate ChatGPT into WordPress?
When you integrate ChatGPT into your WordPress sites, your productivity, engagement, SEO and cost efficiency will gain concrete benefits.
- Fast Content Production: Create blog posts, outlines, meta descriptions, and code snippets in only minutes, overcoming writer’s block and speeding up publishing workflow.
- Better 24/7 Support: Chatbots (AI) provide instant responses, reduce bounce rates, and keep site visitors engaged. Visitors who use live chat spend 60% more time on a site than those who do not.
- Support Cost Reduction: If well programmed, chatbots can handle 30% of support responsibilities and decrease support costs. Businesses report up to 30% reduced support costs, with an average ROI of 1,275%.
- Data and Smart SEO: Chatbot logs show the pain points of users, what they searched to get to the site, or how they applied your products/services. You will develop blog content with keywords. Auto-generated SEO tags, headings, and snippets will keep you optimizing.
How to Integrate ChatGPT into WordPress (Using OpenAI API)
If you want to create a custom setup for integrating ChatGPT into your WordPress site, here are the steps that you can go through to manually integrate ChatGPT into WordPress.
Step 1: Get Your OpenAI API Key
- Sign Up at OpenAI: Navigate to OpenAI’s platform and sign up. In case you have already signed up, simply sign in with the account you signed up for before. Thereafter, navigate to the View API key option.

- Generate an API Key: Then, simply head to the API keys section, create a new secret key, and then copy it by clicking on the copy button.

Step 2: Install any Third Plugin
- Upload the Plugin: You can use any plugin for this purpose. In this example, we will be using the WP AI Assistant. This plugin will let you create chatbots for your WordPress site, which will further help answer your customers’ queries. Simply navigate to the Install plugin option or you can also upload the plugin if you have already saved it in .zip format. Also, do not forget to activate the plugin.

- Paste the API Key:
- The plugin you installed will now appear in the left menu of your WordPress dashboard.
- Simply navigate to the Settings of the plugin.

- The API key that you have copied for OpenAI, simply paste it into the Settings of the installed plugin.

Step 3: Create an AI Assistant
- Navigate to the WP AI Assistant menu and click on the Create Assistant option.

- Then, give your AI Assistant a name and save the changes by clicking on Save Changes.

Step 4: Set up the AI Assistant
- Assistant setup: Simply just click on the Flag icon to set up the name and position of your AI assistant. You can also choose to set it as a floating button on your screen and can even make it appear on all the pages of your WordPress site.

- Assistant Instructions:
- Simply just scroll down, and you will find some recommended instruction settings for your AI assistant. There, you can set the name as well as a nickname, the target, and goals, and you can even custom data usage for your AI assistant.

- You can even try out some of the optional settings such as first message, types of content, content length and tone, and example of reply.

- Simply just scroll down, and you will find some recommended instruction settings for your AI assistant. There, you can set the name as well as a nickname, the target, and goals, and you can even custom data usage for your AI assistant.
- Train your AI Assistant: You can also train your AI chatbot using data. You can use the data from WordPress, documents such as PDFs, text files, etc., or even from external URLs. This also keeps your users informed of the latest trends.

- Customize your Chatbot Design: You can even customize your AI chatbot’s design according to your website’s theme by setting the chat size, background color, font, button color, and even the message color.

- Some Advanced Settings: Inside the advanced settings of your AI assistant, you can set the OpenAI model you want for your chatbot, the input and output tokens, and some features for the model, such as file search and code interpreter.

- Publish your AI Assistant: You can preview your AI chatbot before you feel confident enough to publish it.

How to Integrate ChatGPT into WordPress (Using Shortcodes)
With shortcodes, you can embed a ChatGPT chatbot anywhere on your website by simply inserting a line like [chatgpt_bot] – under the cover, this can load the interface, connect to the API, and display results.
Step 1: Get Your ChatGPT API Key
Before we can do anything, you need access to the OpenAI API and create the API key just like you did before in the previous steps.
Note: You should keep your API key safe, and never publish it on the frontend.
Step 2: Create a Custom Plugin or Use functions.php
There are two ways to include the shortcode functionality:
Option A: Insert Code into functions.php
- Navigate to your theme directory by going to Appearance, followed by Theme File Editor.
- Insert the code into functions.php.
Note: This is not suitable for long-term projects or themes that receive frequent updates.
Option B (Recommended): Make a Simple Plugin
- Navigate to /wp-content/plugins/ in your WordPress root directory.
- Make a new folder named chatgpt-shortcode. This folder will contain the code for your plugin.
- Within it, make a file named chatgpt-shortcode.php. Make sure that the filename matches the folder name that you provided.
- Then paste the code inside that file.
Now, you can add the below code by following either of the two options discussed:
<?php
/**
* Plugin Name: ChatGPT Shortcode Integration
* Description: Integrate ChatGPT using a simple shortcode.
* Version: 1.0
* Author: Your Name
*/
function chatgpt_shortcode_output() {
ob_start(); ?>
<div id="chatgpt-container">
<textarea id="chatgpt-input" placeholder="Ask me anything..."></textarea>
<button onclick="sendToChatGPT()">Send</button>
<div id="chatgpt-response"></div>
</div>
<style>
#chatgpt-container {
max-width: 500px;
margin: 20px auto;
padding: 20px;
background: #f4f4f4;
border-radius: 10px;
}
textarea {
width: 100%;
height: 80px;
padding: 10px;
margin-bottom: 10px;
}
button {
padding: 10px 20px;
background: #0073aa;
color: #fff;
border: none;
cursor: pointer;
}
#chatgpt-response {
margin-top: 20px;
background: #fff;
padding: 15px;
border-radius: 5px;
}
</style>
<script>
async function sendToChatGPT() {
const input = document.getElementById('chatgpt-input').value;
const responseDiv = document.getElementById('chatgpt-response');
responseDiv.innerHTML = "Thinking...";
const response = await fetch('<?php echo admin_url('admin-ajax.php'); ?>', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
action: 'process_chatgpt',
prompt: input,
})
});
const result = await response.json();
responseDiv.innerHTML = result.message;
}
</script>
<?php
return ob_get_clean();
}
add_shortcode( 'chatgpt_bot', 'chatgpt_shortcode_output' );
Step 3: Handle the Backend AJAX Request
In that same plugin file, below the code above in Step 2, add the following:
add_action( 'wp_ajax_process_chatgpt', 'handle_chatgpt_ajax' );
add_action( 'wp_ajax_nopriv_process_chatgpt', 'handle_chatgpt_ajax' );
function handle_chatgpt_ajax() {
$prompt = sanitize_text_field($_POST['prompt']);
$api_key = 'YOUR_OPENAI_API_KEY_HERE';
$endpoint = 'https://api.openai.com/v1/chat/completions';
$data = [
'model' => 'gpt-3.5-turbo',
'messages' => [
['role' => 'user', 'content' => $prompt],
],
'max_tokens' => 150,
'temperature' => 0.7,
];
$response = wp_remote_post($endpoint, [
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $api_key,
],
'body' => json_encode($data),
]);
if (is_wp_error($response)) {
wp_send_json_error(['message' => 'Failed to connect to ChatGPT.']);
}
$body = json_decode(wp_remote_retrieve_body($response), true);
$message = $body['choices'][0]['message']['content'] ?? 'No response from ChatGPT.';
wp_send_json_success(['message' => nl2br(esc_html($message))]);
}
Step 4: Activate the Plugin and Use The Shortcode
- Go to your WordPress Admin area.
- Navigate to Plugins and then to the Installed Plugins section.
- From there, click on Activate ChatGPT Shortcode Integration.
Now, create any Post or Page and insert the below shortcode:
[chatgpt_bot]
Bonus: Add Shortcode Parameters (Optional)
You can extend this shortcode to include parameters like:
[chatgpt_bot placeholder="Type your question here..." model="gpt-4"]
To support parameters, you will have to update your shortcode function like this:
function chatgpt_shortcode_output($atts) {
$atts = shortcode_atts([
'placeholder' => 'Ask me anything...',
'model' => 'gpt-3.5-turbo',
], $atts);
ob_start(); ?>
<!-- Modify textarea and JS to use $atts['placeholder'] and $atts['model'] -->
<?php
return ob_get_clean();
}
And pass the model parameter to your Ajax request using hidden inputs or JavaScript variables.
Top 5 Most Popular ChatGPT Plugins for WordPress
Here is a list showcasing the 5 most popular WordPress plugins that you can easily use in your WordPress site.
1. Jetpack AI Assistant

Automattic created Jetpack AI Assistant. They added an AI block right in the Gutenberg editor. It uses GPT-4 to create blog posts, headlines, tables, and images, with Rs. 290.95 per month. It can also fix your grammar and change the tone of your content to elevate it. These features make it an ideal choice for content creators.
2. AI Mojo

AI Mojo (Bring Your Own Keyword plugin) is a plugin focused on keyword content. It has built-in templates—outlines, introductions, and conclusions—and allows for rewriting text. It’s free, but to use this plugin, you’ll have to use your own OpenAI API key. Marketers interested in writing SEO-optimized content will find it a good fit.
3. AI Engine

AI Engine has a multitude of options for text generation, chatbots, and image making, and it offers AI tools right inside WordPress. It uses models by OpenAI, Anthropic, and others. The plugin is also immensely popular, with over 100,000+ active installs, and has a 4.9 review score. This plugin has strong community adoption and trust.
The free version contains most features and the core capabilities. The Pro version features advanced dashboards, model training using your data, and usage analytics. The Pro version is approximately $49 per year.
4. AI Power (GPT AI Power)

AI Power brings models like GPT‑3.5/4, Gemini, and more together in one plugin. This plugin provides bulk content features. You get options like WooCommerce product descriptions, chat widgets, and form AutoGPT. All this is available for just $9.99 a month. It’s a smart choice for e-commerce sites needing content AI and conversational AI.
5. AI Assistant With ChatGPT

AI Assistant with ChatGPT plugin is for front-end visitors, but also site admins. For front-end visitors, it acts as a chat and question, and assistance tool. Site admins can access it from the dashboard. This will help them with WordPress tasks and save time searching for external documentation. You can choose between a free plan and a premium plan.
Conclusion
Adding ChatGPT to your WordPress site can automate tasks. It also adds value with smart content, better support, and a more engaged user experience. Whether you take the no-code approach using a plugin or go the long route with the API, you will benefit from both sides:
- You get a full-time AI support agent that helps visitors to your site, decreasing bounce rates. Chat interaction encourages users to stay and explore more content.
- Create SEO-rich content right away. This includes blog posts, meta descriptions, and WooCommerce product descriptions. You’ll save several hours each week.
- You will cut support time and costs by automatically answering routine questions. Chat data will uncover trending questions that can help inform your content strategy moving forward.
Lastly, once you are onboard ChatGPT, you can go even further in optimizing. You can tweak prompt settings according to usage metrics, keeping them in sync with your brand voice, user journeys, and budgets.

Yogesh Rude
Yogesh Rude is an SEO and content writer at DevDiggers who focuses on eCommerce visibility and on-page optimization. His guides cover the SEO decisions WooCommerce store owners face most often, including product page structure, metadata strategy, and how search engines interact with site content.
Join thousands of readers getting smarter every week.

Leave a Reply