Archived topic
How does ChatGPT store their Chat history on the side for future reference?
15 replies · Started by Jason on February 26, 2023
Hi Guys,
I've been trying for a whole week to find a solution, to save user generated text files like 1000 words files, from users that sign up and visit my wordpress website, kinda the same way as ChatGPT saves their down the left column. (photo attached) And when you click on it, it looks like it brings up a post associated with the user that made it, and stores all the chat history. How can I achieve this? what's the easiest database to save files like chat, or text? I tried looking at SQL, but its kinda tough and looks outdated, are there easier solutions now? Any help would be appreciated.
I tried, SQL, thinking it would easily send files there, but I was wrong. I tried user post for each submission to be saved as a post, I tried email, but doesn't work.
on my localhost I was able to save all the generated text files as .txt or .docx, but when I try the same method on my wordpress site, the files never appear anywhere, I enabled permission, so I dunno what to do now. Could you guys suggest something? I only need one folder per Wordpress user/member, on the left side, called "My Content" and where all their generated text files get saved automatically.
Right now they come back via successful text that is generated by an API call from openai, everything works fine, with the response text, but I'm trying to figure how to store the response text. is there maybe a plugin that maybe does this? thank you very much .
I also included a link to my test site, which is working in generating text, but not saving them

I also found another site whose layout I like, when you click on the article it brings up a specific ID /article-generator/?id=2916409
which brings up the below, which to me looks like an online word doc. looks very similar to Word.

Hi there,
the standard way of WordPress is that every piece of content is saved in a "Post" ( whether that be a post, page or custom post type ). That data is saved with Post Meta which can include data such as the Author.
If you adhere to that method, then listing what a user has added as a "post" should be fairly straight forward.
thanks for your reply, what if the response is coming back via API from openai? do I just create a post with javascript, via method 'POST' with a JSON file? as below.
or since it's wordpress, am I forced to use .php? this is where I get stuck, if I have to use .php in order to create the post. thank you.
const options = {
url: 'enterurl',
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
json: newPost
};
PHP would be simplest, here is one method using wp_insert_post https://stackoverflow.com/a/34435434
Or you can check out the REST API:
https://developer.wordpress.org/rest-api/
And theres an npmjs package for that too ( if thats of interest ):
https://www.npmjs.com/package/wpapi
The main thing with any of these methods will be the authentication, so a user being logged in to the WP site, and using PHP or REST would probably be the least fuss
oh u mean node.js? i was trying to work what that was for a full day lol, yeah the initial API call comes back using node.js from the server side. I think will be easier to add a save button after the response text comes back, so it posts it, but I never done this before so it's all a bit confusing.
Yeah, node but you would need to configure that on your server.
Check the wp_insert_post function - looks fairly straightforward:
https://developer.wordpress.org/reference/functions/wp_insert_post/
do you mean server side, as in the backend? or do you mean the client side, front end, where my wordpress site is hosted?
Yeah it should be straight foward, though it's my first time doing APIs and splitting a site with backend and front end. Thanks again.
in our space, the Front End is what we the user sees in the browser.
The backend is the WordPress Admin down to the server.
So in this instance the PHP function would run in WordPress ( backend ), so it could be added to the template that you have for your form, or as separate function.
ok thanks for your help. I will give that a shot, cheers
You're welcome - be good to hear how you get on!
I will let you know, but I had some javascript conflict with the code, hence why it wasn't even creating a post. So I have to rearrange some of the code around so the form works with the sliders I have on there, and can therefore save the response text as a post.
hey there, Just wondering if you guys have any service to assist in php or javascript functionality, for a fee?
Just thought I'd ask here before going on Upwork etc. thank you.
Hi Jason,
We don't.
Upwork or Codeable suggested at the bottom of this page would be your best bet:
https://generatepress.com/what-support-includes/
thanks for that, I will check it out, cheers