Error: Duplicate request detected.
-
When I write “Hi” (once) I receive “Error”
Test email log:
New Chatbot Conversations Digest
[2025-12-18 18:32:20] Visitor: Hi (it’s mine)
[2025-12-18 18:35:21] Visitor: Hi (I don’t know what is it)
[2025-12-18 18:35:21] Chatbot: Error: Duplicate request detected. Please try again.<br><br>
And when I try to clear – “Oops! Unable to clear conversation. Please try again.”
-
Hello limest (@limest),
Here is a description of what I think is happening:
- Duplicate Request Error: When sending a message (e.g., “Hi”), the chatbot returns “Error: Duplicate request detected. Please try again.” even though it’s the first message.
- Clear Conversation Failure: When attempting to clear the conversation, you receive “Oops! Unable to clear conversation. Please try again.”
I’m belive the issues is caused by:
- Stale Duplicate Detection Transients: The plugin uses message UUID transients to prevent duplicate requests. These transients were set with a 5-minute expiration but were not being cleared when users cleared their conversations. This caused legitimate new messages to be flagged as duplicates.
- Overly Strict Session Validation: The session ownership verification function was too restrictive, rejecting valid session IDs that didn’t match the exact expected format, preventing conversation clearing for some users.
- Missing Transient Cleanup: When clearing conversations, the duplicate message UUID transients were not being purged, leaving stale data that interfered with new messages.
I have a fix that includes three key improvements:
- Added Transient Cleanup: When a conversation is cleared, all duplicate message UUID transients are now properly cleared to prevent false positive duplicate detection.
- Improved Session Validation: Made the session ownership verification more flexible to accept valid session IDs while maintaining security.
- Reduced Timeout Duration: Reduced the duplicate detection timeout from 5 minutes to 2 minutes to minimize the window for false positives.
To implement this fix, I’ve made several mofications to chatbot:
- Added transient cleanup and improved session handling
- Reduced duplicate detection timeout from 300 to 120 seconds
Below is a link to a quick fix to the plugin.
- Backup your WordPress installation before proceeding.
- Download the patched plugin here: https://kognetiks.com/wp-content/uploads/2025/12/chatbot-chatgpt.zip
- Upload and replace the existing plugin on your site.
- Activate the plugin.
- Go to the Chatbot Settings, click the Messages tab and confirm you’re running Version 2.4.0 (this fix).
- Clear cache(s) in WordPress and on your Server.
- Test again.
Let me know if this resolves your issue. Once confirmed, I’ll make an official release.
Best,
Stephen
Hi, Stephen and thank you.
Unfortunately, it didn't help.
When sending a message (e.g., “test”), the chatbot returns “error”.
I did as you recommended. I've cleared and disabled LiteSpeedCache plugin, cleared Cloudflare cache.
This is my system:
Chatbot Version: 2.4.0
PHP Version: 8.3.25
PHP Memory Limit: 1024M
WordPress Version: 6.9
API STATUS: Success: Connection to the OpenAI API was successful!
I haven't been monitoring the use of the plugin for several months, so I can't even say when exactly the problem appeared.
These logs may be helpful:
[Chatbot] [ERROR] [2025-12-20 17:24:23] [Session ID: N/A] [User ID: 1] [IP Address: xxxxxx] [Error:] []
[Chatbot] [ERROR] [2025-12-20 17:24:59] [Session ID: N/A] [User ID: 1] [IP Address: xxxxxx] [Error:] []
[2025-12-20 17:30:53] [Chatbot] [Advanced Reset] Cache and locks reset by admin user ID: 1 - Cleared 55 entries
Test email from the Chatbot Conversation Digest system (my message appears 2-3 times, even though I only sent it once):
[2025-12-20 19:14:20] Visitor: hi
[2025-12-20 19:17:09] Visitor: hi
[2025-12-20 19:17:11] Chatbot: The system is busy processing requests. Please try again later.
[2025-12-20 19:55:51] Visitor: test
[2025-12-20 19:58:53] Visitor: test
[2025-12-20 20:01:54] Visitor: test
I found out that the OpenAI platform logs contained the following inputs:
System: You are a test function for Chat.
User: Write a one sentence response to this test message.
Instead of my messages. And as I see it, these are some kind of test inputs for the chatbot, not my “hi” messages to the assistant.Hello limest (@limest),
I made a few changes to the error logging to see if we can catch what might be going on.https://kognetiks.com/wp-content/uploads/2025/12/chatbot-chatgpt.zip
As before, download this zip file and replace the chatbot with this version (it will still show 2.4.0 as the version).
Then clear caches (server, wordpress, etc.).
Once we can catch the actual error we may be in a position to figure out what is going on.The message …
You are a test function for Chat.
API STATUS: Success: Connection to the OpenAI API was successful!… is being sent when you access the chatbot settings and click on the Messages tab and you get the “Success” response.
So, we know that you’re able to reach the OpenAI platform via the API.
Can you check again? Let me know what you find.
If there anything in the debug.log file that would be helpful.
Best,
StephenThank you.
I installed the new version and checked it.My debug.log:
[Chatbot] [chatbot-analytics.php] Translation file not found for uk. Falling back to: /www/wp-content/plugins/chatbot-chatgpt/includes/analytics//languages/en_US.php
PHP Warning: Cannot modify header information – headers already sent in /www/wp-content/plugins/chatbot-chatgpt/chatbot-chatgpt.php on line 58
The chatbot error log only shows:
[Chatbot] [ERROR] [2025-12-20 19:31:15] [Session ID: N/A] [User ID: 1] [IP Address: xxxxxx] [Error:] []
I just discovered one nuance – it occurs when I use the assistant shortcode [chatbot-2] instead of the shortcode [chatbot]. The shortcode appears only once on the page. If I use the universal shortcode [chatbot], I get both the logs on the OpenAI platform and the bot’s responses. But not my assistant’s. But I have a shortcode configured in the GPT Assistants section. I’m confused.Hello limest (@limest),
There is not a specific translation file for the UK so the chatbot defaults to US when there is no specific match. There are translation file for CS, DE, ES, FR, IT, PL, PT and RU. I’ll fix the error on line 58.
Here is a link to an updated version:
https://kognetiks.com/wp-content/uploads/2025/12/chatbot-chatgpt.zipTo clarify, [chatbot] calls the general OpenAI chatbot API. When using [chatbot-n] where n = 1, 2, etc., it’s specifically calling the API to access your assistants on the OpenAI platform (a different API endpoint at OpenAI).
The chatbot was not designed to invoke more than one chatbot on the site. The use case for having a mulitple bots on the same page – for example one embedded on the page that call as assistant and one in footer that calls the general chatbot or a different assistant but is floating – is something I’ve been pondering for a while.
I’ll see what I can do to prioritize supporting multiple chatbots on the same page.In the meantime, let me know if this latest version clears up the issues you’re experiencing.
Best,
Stephen
Thank you for the quick response and the updated version!
Important clarification: I only have ONE shortcode on my site: [chatbot-2] which calls a single assistant. I don’t use multiple chatbots on the same page. The issue was that this single assistant shortcode wasn’t working at all (returning “error” with no response), while [chatbot] (general API) worked fine.
I tested the version you provided, but still encountered some issues that I had to fix:
1. Headers Already Sent Warning (line 58)
The setcookie() in kognetiks_assign_unique_id() still triggers a warning when headers are already sent. I added a headers_sent() check:if (!headers_sent()) {
setcookie(...);
}2. Infinite Retry Loop on Failed Runs
When OpenAI returns status: failed, the code keeps creating new runs in an infinite loop until timeout. I added detection of failed status and automatic stop after a few consecutive failures.3. Root Cause of My Original Issue
The assistant was failing because:max_prompt_tokenswas set too low (2000) for my assistant instructions (~5000+ tokens)- The model was returning server_error with very long instructions
- I had file_search enabled without a Vector Store attached
After shortening my instructions and moving content to a Vector Store file, everything works now.
4. Ukrainian Translation Files
I created translation files for my Ukrainian-Spanish site:- uk.php
- chatbot-globals-uk.php
If you’re interested, I can send you the Ukrainian translation files for other Ukrainian users.
Best regards
Hello limest (@limest),
Thank you for the additional testing.
I’ve made a small change in the code to address the headers sent warning you’re getting.
I’ve also made a change in the number of retries for failed attempts (now limited to 3).
This should resolved the infinite loop problem you are experiencing.
I’ve added support for Ukainian translations.
Before downloading and testing the version below you should back up your UK translation file.
I used ChatGPT to create the translations. I would appreciate your review of contents.
Feel free to provide me with your version of the UK translation file. More than happy to incorporate it.
As for the max token setting for assistant, OpenAI recommends using 20,000.
More details about this setting can be found in the Advanced Additional Settings documentation here:
https://kognetiks.com/docs/assistants-manage-assistants/And here:
https://platform.openai.com/docs/assistants/deep-dive#max-completion-and-max-prompt-tokens
Please download and install this update and let me know if there are any further issues.
https://kognetiks.com/wp-content/uploads/2025/12/chatbot-chatgpt.zip
Best,
StephenHi Stephen,
Thank you for the quick update! I downloaded and checked the latest version from your link, but I noticed the changes you mentioned don’t appear to be included:
1. Headers Already Sent Warning
The kognetiks_assign_unique_id() function in chatbot-chatgpt.php (lines 53-63) still has setcookie() without a headers_sent() check.2. Retry Limit
In chatbot-call-openai-api-assistant.php $maxRetries is still set to 10, not 3.Also, there’s no detection of consecutive failed status to stop retrying early when OpenAI keeps returning errors.
3. Ukrainian Translation Files
The following files are not present in the ZIP:- chatbot-globals-uk.php
- uk.php
Only CS, DE, EN, ES, FR, IT, PL, PT, and RU are included.
Could you please verify you uploaded the correct ZIP file? Perhaps an older version was uploaded by mistake?
I’ve implemented my own fixes for all the issues mentioned, so I consider this resolved on my end. I’m happy to share my changes if useful for the official release.
Thank you!
Best regards
Hello limest (@limest),
Here is the updated zip file:
https://kognetiks.com/wp-content/uploads/2025/12/chatbot-chatgpt.zipLet me know if there are any open issues that remain.
Best,
Stephen
You must be logged in to reply to this topic.