Table of Contents
ToggleThis guide compares plugins, server-side API calls and event automation for WordPress. Check credentials, permissions, cost and data handling before choosing a route. The examples explain the request flow; they are not a production-ready deployment.
How to Use This Guide
- Start with the basics. Understand the difference between the ChatGPT app and the OpenAI API.
- Pick your path. If you don’t want to code, use a plugin. Consider custom code when you need a separate permissions policy or interface. Custom code is not automatically more secure. For routine work, consider no-code automation.
- Use an access-controlled test environment to check responses, failures, cost and data handling before deployment. A public temporary page alone is not isolation.
Basics in 3 Minutes
Documentation reviewed on 13 October 2026. For a new custom integration, start with the Responses API. Chat Completions remains supported; the code below illustrates that compatibility path, not the default for a new project.
The examples use gpt-4o-mini as a specific example, not a claim that it is the newest or best model. Check the model documentation and your project access. In Chat Completions, max_tokens is deprecated in favor of max_completion_tokens; Responses uses max_output_tokens. Changing only the URL or parameter name is not a complete migration: the request body and response parser differ. See the Chat Completions reference.
- ChatGPT (app) is for direct conversation in a web/app UI. OpenAI API is how your site talks to the model from the server.
- Generative AI creates new text or images from patterns it learned. Most models use the Transformer architecture.
- Key settings:
model(response characteristics and cost),temperature(sampling variability where supported),max_tokens(an example output-token limit). Option names and support vary by model and API; sampling settings do not guarantee factual accuracy. - Shortcode is WordPress’ bracket tag you place in posts/pages to add features.
- REST endpoint connects browser requests to server code. Browser → WordPress → OpenAI does not by itself implement authorization or abuse prevention.
Pre-Flight Check (Required)
- Check API project credentials, billing and usage. ChatGPT subscription billing is separate. Do not treat a budget alert as an application-level hard stop.
- Make sure you have WordPress admin access.
- Create a temporary test page.
max_tokens cap does not bound input-token, repeated-call or tool costs.🔑 OpenAI API Key Setup (True Beginner Guide)
4.1 Method 1: Create an API key in the OpenAI console
- Log in to the OpenAI Platform. Choose or create a Project.
- Go to Settings → API keys, click Create new secret key, and store it safely.
curl https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"model":"gpt-4o-mini",
"messages":[{"role":"user","content":"test"}],
"max_tokens":30
}'
api.openai.com in your hosting firewall.4.2 Method 2: Store and rotate the key safely
- Store the key server-side using
wp-config.phpor environment variables. - Use least-privilege keys per project; disable unused keys.
- Review usage and rotate keys according to your policy. Suspected exposure requires revocation and replacement, not just a scheduled review.
- Restrict access to server logs.
4.3 Method 3: Save the key inside WordPress (plugin or custom)
- For plugins, paste the key in the plugin’s “API Keys” screen.
- For custom setups, define it in
wp-config.phpand read it on the server only.
/* Add below the DB settings */
define('OPENAI_API_KEY','YOUR_REAL_API_KEY');
Choose Your Path: Plugin vs Custom vs Automation
| Path | Strength | Best for | Difficulty |
|---|---|---|---|
| Plugin | Fast to ship; ready-made chat UI and settings. | Need quick results. | Easy |
| Custom | Control over permissions, requests and branding, with corresponding development and validation work. | Policies, permissions, future growth. | Medium–Hard |
| Automation | No-code connections for WordPress events. | Form submissions and after-publish tasks. | Easy |
Start with Plugins
Current plugin documentation needs version and license checks. AI Engine also supports WordPress tools through MCP; administrative tool access is a separate use case from a visitor chatbot and requires restricted permissions. AI Puffer offers Cloud or your own provider account. Do not treat a plugin feature list as proof that an old API mode still works: OpenAI lists the Assistants API shutdown as 26 August 2026 in its deprecation schedule. Check the plugin’s replacement path before enabling a legacy Assistants integration.
6.1 Recommended plugins & how to choose
- AI Engine — chatbot, AI forms, content tools, internal API, shortcodes.
- AI Puffer (formerly AI Power) — now documented as AI Puffer; check current chatbot, content, image and automation features, provider support and Cloud versus own-key requirements.
- WPBot — support/FAQ-focused features; Messenger/WhatsApp add-ons.
- AiBud WP — template-based content & images; simple chatbot.
- WPForms + OpenAI — connect forms to OpenAI via Uncanny Automator or Zapier.
6.2 Quick pick table
| Plugin | Strength | Scenario | Embed |
|---|---|---|---|
| AI Engine | Chatbot, post generation, prompt library, add-ons. | Consider for combined chatbot/content workflows. | Block / Shortcode |
| AI Puffer (formerly AI Power) | Multi-model, bulk content, WooCommerce support. | E-commerce and large-scale creation. | Block / Shortcode / Widget |
| AiBud WP | Easy templates and Playground. | Simple setup for beginners. | Block / Shortcode |
| WPBot | Support, lead capture, messenger add-ons. | FAQ & chat bubble across pages. | Widget |
| WPForms + OpenAI | AI replies and summaries from form input. | Contact/support/lead forms. | Form embed |
6.3 Detailed plugin how-tos
6.3.1 AI Engine (Meow Apps)
VISITOR CHATBOT · LAYOUT EXAMPLE
- Install and activate the plugin.
- Check the current AI Engine provider settings and API Keys: verify the menu and shortcode options for your installed version before registering the key.
- Create a bot in Chatbots, then copy the shortcode into a page.
[mwai_chatbot theme="bubble" window="embedded" max_messages="6" bot_name="Helper"]
temperature without treating them as factual-accuracy controls. For truncated output, check the finish reason and model-specific limit; increasing max_tokens alone does not guarantee useful answers.6.3.2 AI Power (GPT AI Power)
- AI Power is now documented as AI Puffer. Check its current connection settings and distinguish own-key credentials from Cloud authentication and billing.
- Enable only the modules you need (Chat, Content Writer, Image, Agents, …).
- Embed via block, shortcode, or widget.
6.3.3 WPBot / ChatBot for WordPress (Social Intents)
- For WPBot: set language, UI, and greeting in WPBot → Settings. Use add-ons for OpenAI/Messenger/WhatsApp.
- For Social Intents: build the bot in their dashboard, connect the WP plugin, and show a site-wide chat bubble/popup.
6.3.4 AiBud WP
- Check AI Bud’s current provider/key settings; menus and module availability depend on version and license.
- Use Content Builder, Playground, or ChatBot as needed.
6.3.5 WPForms + OpenAI
- Create a form in WPForms; connect the trigger in Uncanny Automator or Zapier.
- Send only permitted fields to the provider and review generated output before using it in confirmations, email or CRM records.
Custom: Server-Side Requests and Access Control
The browser calls your WordPress REST endpoint. WordPress calls OpenAI from the server. This keeps the key out of the browser but does not prevent abuse of the endpoint. The __return_true permission callback below does not restrict callers. Review authorization, input length, rate/cost controls and error-detail exposure before any production deployment.
7.1 Store the key in wp-config.php
define('OPENAI_API_KEY','YOUR_REAL_API_KEY');
7.2 Create a REST endpoint
add_action('rest_api_init', function(){
register_rest_route('ai/v1','/chat',[
'methods'=>'POST',
'callback'=>'my_ai_chat_handler',
'permission_callback'=>'__return_true' // tighten in production
]);
});
function my_ai_chat_handler( WP_REST_Request $req ){
$msg = wp_strip_all_tags( $req->get_param('message') );
if(!$msg) return new WP_Error('bad_request','message is required',['status'=>400]);
$payload = [
"model"=>"gpt-4o-mini",
"messages"=>[
["role"=>"system","content"=>"You are a helpful WordPress assistant who answers in English."],
["role"=>"user","content"=>$msg]
],
"max_tokens"=>500,"temperature"=>0.6
];
$res = wp_remote_post('https://api.openai.com/v1/chat/completions',[
'headers'=>[
'Authorization'=>'Bearer '.OPENAI_API_KEY,
'Content-Type'=>'application/json; charset=utf-8'
],
'timeout'=>45,
'body'=>wp_json_encode($payload)
]);
if(is_wp_error($res)) return new WP_Error('api_error',$res->get_error_message(),['status'=>500]);
$code = wp_remote_retrieve_response_code($res);
$body = json_decode( wp_remote_retrieve_body($res), true );
if($code<200||$code>=300) return new WP_Error('api_error','OpenAI error',['status'=>$code,'detail'=>$body]);
return ['reply'=>$body['choices'][0]['message']['content'] ?? '(no response)'];
}
7.3 Shortcode & front-end UI
What this snippet actually builds: a text field and a Send button. To make the illustrated UI work, also implement the browser request handler, server access and abuse controls, safe reply rendering, and sending/error states. Copying this shortcode alone does not create a working chatbot.
CUSTOM UI · INTENDED RESULT
add_shortcode('my_chatgpt', function(){
ob_start(); ?>
<div id="my-chat" style="border:1px solid #e6eef6;border-radius:12px;padding:16px;background:#fff">
<div style="font-weight:700;margin-bottom:8px">💬 ChatGPT Assistant</div>
<div id="my-chat-log" style="min-height:120px;padding:10px;border:1px solid #e6eef6;border-radius:8px;overflow:auto"></div>
<div style="display:flex;gap:8px;margin-top:10px">
<input id="my-chat-input" type="text" placeholder="Ask a question…" style="flex:1;padding:10px;border-radius:8px;border:1px solid #d9e3ee" />
<button id="my-chat-send" type="button" style="padding:10px 14px;border-radius:8px;background:#667eea;color:#fff;border:none;cursor:pointer">Send</button>
</div>
</div>
<script>
(function(){
const log=document.getElementById('my-chat-log');
const input=document.getElementById('my-chat-input');
const btn=document.getElementById('my-chat-send');
function bubble(text,who){
const w=document.createElement('div'); w.style.margin='8px 0';
const bg= who==='me' ? '#e0f2fe' : '#eef2ff', fg= who==='me' ? '#0c4a6e' : '#1e293b';
w.innerHTML='<div style="background:'+bg+';color:'+fg+';display:inline-block;padding:8px 10px;border-radius:10px;max-width:90%">'+
text.replace(/</g,'<').replace(/>/g,'>')+'</div>';
log.appendChild(w); log.scrollTop=log.scrollHeight;
}
async function send(){
const msg=input.value.trim(); if(!msg) return; bubble(msg,'me'); input.value=''; bubble('Typing…','bot');
try{
const res=await fetch('<?php echo esc_url( rest_url('ai/v1/chat') ); ?>',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({message:msg})});
const data=await res.json();
log.lastChild.innerHTML='<div style="background:#eef2ff;color:#1e293b;display:inline-block;padding:8px 10px;border-radius:10px;max-width:90%">'+
(data.reply||'No response').replace(/</g,'<').replace(/>/g,'>')+'</div>';
}catch(e){
log.lastChild.innerHTML='<div style="background:#fee2e2;color:#7f1d1d;display:inline-block;padding:8px 10px;border-radius:10px;max-width:90%">Error: '+(e.message||e)+'</div>';
}
}
btn.addEventListener('click',send); input.addEventListener('keydown',e=>{ if(e.key==='Enter') send(); });
})();
</script>
<?php return ob_get_clean();
});
7.4 Harden security (nonce, rate limit, cache)
- For logged-in REST requests, validate the nonce and actual user permissions. A nonce is not authentication or authorization; anonymous access needs its own policy.
- Limit calls per IP/session per minute.
- Separate user-specific data and permissions before caching responses. Do not mix personal responses in a shared cache; measure any cost benefit.
- Control sensitive-data collection and external transfer at the input layer. Prompt instructions or blocked-word lists alone are not a privacy safeguard.
No-Code Automation: Uncanny Automator / Zapier
8.1 New post → summary → auto-post to social
- Trigger: Post published.
- Action: Create a summary with OpenAI.
- Action: Review the caption, then publish through an approved social connection. Define stop and error handling for automatic publication.
8.2 Form submitted → personalized email
For structured CRM fields or classifications, use schema-constrained output where supported, then validate it on the server. Handle refusals, incomplete results and failed requests before sending messages or writing records; schema compliance does not establish factual correctness.
- Trigger: WPForms submission.
- Action: Send only permitted form fields to OpenAI and generate a draft reply.
- Action: Review content and recipient before sending; retain only necessary CRM data.
8.3 WooCommerce events
- Trigger: new order / return / question.
- Action: Generate order summary, FAQ, or how-to guide.
- Action: Send admin alerts / write to Sheets / create tickets.
Operations Guide
9.1 System prompt example
You are a WordPress assistant who answers in clear, simple English.
- Keep answers within 5 sentences when possible.
- Include code blocks if code is needed.
- Do not request or store personal data. Ask follow-up questions when unclear.
9.2 Cost control checklist
A spend alert sends a notification and leaves API traffic running. An enabled organization or project hard spend limit can reject affected requests with a 429 error, but enforcement is not instantaneous and recorded spend may slightly exceed the limit. Check spend-limit settings, and keep application rate limits, usage monitoring and an error path. Documentation review does not verify your account settings or a live paid API call.
- Start with a lightweight model.
- Set caps for
max_tokensand conversation length. - Cache repeated prompts and reuse templates.
9.3 Privacy, security, performance
- Avoid unnecessary sensitive input and explain AI use, external transfer and retention. API training-use policy and log retention are separate; a system prompt does not enforce data-handling controls.
- Load chatbot scripts lazily or only on needed pages.
- Watch Core Web Vitals; exclude critical pages from heavy scripts.
- Review server/app logs regularly.
Testing & Troubleshooting
10.1 Basic checks
- Confirm API key, billing, budget, and rate limits.
- Allow
https://api.openai.comthrough your firewall. - Check SSL and server time sync.
- Set
wp_remote_post()timeoutagainst actual latency and proxy limits. 45 seconds is an example, not a universal minimum. - Test for plugin/theme conflicts.
10.2 Debug the custom REST call
- In DevTools → Network, inspect
/wp-json/ai/v1/chat. - 400: missing
message. 401/403: authentication, permissions or another blocking layer; inspect the response and logs. 500: a server-error category; the status alone does not identify a missing key or upstream cause.
10.3 Elementor placement
- Insert a prepared shortcode through Elementor’s Shortcode widget. Do not paste PHP examples into an HTML widget expecting them to execute; manage reviewed server code separately.
- Compare saved source with delivered output, then use the existing page-cache refresh procedure when needed.
- Compare optimizer behavior in a limited test before adding a specific exception; do not add broad exclusions without evidence.
FAQ
charset=utf-8 label and cache refresh do not repair text already corrupted in storage.Appendix
12.1 Extended plugin comparison table
| Plugin | Main features | Models/Providers | Ease | Notes |
|---|---|---|---|---|
| AI Engine | Chatbot, AI forms, post generation, prompt library. | OpenAI + others | Easy | Check required modules and supported extension paths. |
| AI Puffer (formerly AI Power) | Chat, writer, image, voice, automation, agents. | OpenAI / Google / Anthropic, etc. | Medium | Great for all-in-one operations. |
| WPBot | Support/FAQ; Messenger & WhatsApp add-ons. | OpenAI or Dialogflow | Easy | Best for lead/support sites. |
| AiBud WP | Template-based content & images, Playground, chatbot. | OpenAI | Easy | Friendly for beginners. |
| WPForms + OpenAI | AI replies/summaries from form data. | OpenAI | Easy | No-code automation workflows. |
AI Engine
- Build a bot in Settings and embed via shortcode.
- Review Copilot or Magic Wand drafts before applying them.
AI Puffer (formerly AI Power)
- Paste the key in the dashboard, enable modules you need.
- Embed via block, shortcode, or widget.
WPBot
- Configure UI, language, and greeting in Settings.
- Extend with OpenAI or WhatsApp add-ons.
AiBud WP
- Save your key and turn on the modules you want.
- Verify the installed content/chatbot modules on a limited test page first.
WPForms + OpenAI
- Connect WPForms with Automator or Zapier.
- Auto-generate confirmations and notifications.
Uncanny Automator
- Build scenarios with a GUI.
- Automate posts, forms, orders, and more.
12.2 Snippet library
[mwai_chatbot theme="bubble" window="embedded" max_messages="6" bot_name="Helper"]
[my_chatgpt]
12.3 Mini glossary
- API: interface for apps to talk to each other.
- Shortcode: WordPress bracket tag to insert features.
- REST: request/response over standard HTTP.
- Temperature: a sampling-variability setting where supported, not a factual-accuracy guarantee.
- Token: a unit used to process model input and output, not a one-to-one word or character count.
Wrap-Up & Next Steps
Next: use an access-controlled test environment, review response/failure/cost/latency/log evidence, then approve deployment with stop and rollback procedures.
