# Matching GPT user to database records

**URL:** <https://community.openai.com/t/matching-gpt-user-to-database-records/572075>\
**Category:** API\
**Tags:** gpt\
**Created:** [December 26, 2023, 1:55pm UTC](https://community.openai.com/t/matching-gpt-user-to-database-records/572075 "2023-12-26T13:55:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdyildirim](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@mdyildirim](https://community.openai.com/u/mdyildirim)\
**Post date:** [December 26, 2023, 1:55pm UTC](https://community.openai.com/t/matching-gpt-user-to-database-records/572075/1 "2023-12-26T13:55:44Z")

</div>

Hi,

My GPT will be used by various users. I need to record when a user interacts with the GPT. But how will I know which user used it, so that I can match it to the users in my database? Is there some sort of mechanism where we could ask for email & password, or can we somehow get GPT user\_id from OpenAI API?

Thank you,  
Mutlu

---

<div class="post-metadata">

**Author:** ![anon34024923](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@anon34024923](https://community.openai.com/u/anon34024923)\
**Post date:** [December 26, 2023, 5:25pm UTC](https://community.openai.com/t/matching-gpt-user-to-database-records/572075/2 "2023-12-26T17:25:41Z")

</div>

I’d get the users username from your db from when they signed up and pass that to your back end in your req.body and then id pass that ID to the bot and have it give back JSON where one of the parameters is that ID, and then id pass that response from the API to the front end, voila

Example: the users username is ${user}

You are X bot. You do X

…respond in JSON without deviation  
[  
User: ${user}  
Response:  
]

Pass this JSON back to your front end or DB^

Sorry for the crap syntax I’m on my phone at an airport

---

<div class="post-metadata">

**Author:** ![CinematicDev](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@CinematicDev](https://community.openai.com/u/CinematicDev)\
**Post date:** [December 26, 2023, 7:03pm UTC](https://community.openai.com/t/matching-gpt-user-to-database-records/572075/3 "2023-12-26T19:03:15Z")

</div>

OpenAI will send a conversation\_id in the header when it makes an action call as well as the gpt\_id. There is an empheremal\_user\_id but that changes. They do not want you tracking users across OpenAI.

---

<div class="post-metadata">

**Author:** ![matcha72](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/matcha72/32/4667_2.png) [@matcha72](https://community.openai.com/u/matcha72)\
**Post date:** [December 26, 2023, 7:21pm UTC](https://community.openai.com/t/matching-gpt-user-to-database-records/572075/4 "2023-12-26T19:21:13Z")

</div>

You can add Oauth2 authentication to your app and once the user does sign in, the user id is sent along with each request to your server

---

<div class="post-metadata">

**Author:** ![mdyildirim](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@mdyildirim](https://community.openai.com/u/mdyildirim)\
**Post date:** [December 26, 2023, 8:34pm UTC](https://community.openai.com/t/matching-gpt-user-to-database-records/572075/5 "2023-12-26T20:34:10Z")

</div>

> [@matcha72](#):
>
> can add Oauth2 authentication to your app and once the user does sign in, the user id is sent along with each request to your server

thanks, but it’s not exactly my app, it’s the custom GPT I created inside ChatGPT. Would Oauth2 work in this scenario (not an expert in this area)?

---

<div class="post-metadata">

**Author:** ![mdyildirim](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@mdyildirim](https://community.openai.com/u/mdyildirim)\
**Post date:** [December 26, 2023, 8:40pm UTC](https://community.openai.com/t/matching-gpt-user-to-database-records/572075/6 "2023-12-26T20:40:14Z")

</div>

Thanks, good idea. But please note that it’s a custom GPT inside chatGPT, not my app. So the user logs in into chatGPT, and then uses my custom GPT. And I’d like to be able to understand how many questions s/he asks to this custom GPT. I’ll utilize Actions, which allows to call external APIs. All I need is to somehow call those external APIs (which I created) with some sort of ID so that I can match them to the relevant user on my end.

---

<div class="post-metadata">

**Author:** ![mdyildirim](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@mdyildirim](https://community.openai.com/u/mdyildirim)\
**Post date:** [December 26, 2023, 8:42pm UTC](https://community.openai.com/t/matching-gpt-user-to-database-records/572075/7 "2023-12-26T20:42:05Z")

</div>

> [@CinematicDev](#):
>
> OpenAI will send a conversation\_id in the header when it makes an action call as well as the gpt\_id. There is an empheremal\_user\_id but that changes. They do not want you tracking users across OpenAI.

Extremely helpful, thanks! Will give it a try. But it would be very helpful if Actions could also require some sort of login mechanism for the user so that we can have more control over the actions of the user.

---

<div class="post-metadata">

**Author:** ![mdyildirim](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@mdyildirim](https://community.openai.com/u/mdyildirim)\
**Post date:** [December 26, 2023, 9:35pm UTC](https://community.openai.com/t/matching-gpt-user-to-database-records/572075/8 "2023-12-26T21:35:31Z")

</div>

Here’s an interesting idea from chatGPT (I love AI): Another approach is to require users to input their ID (assigned by your app) at the beginning of their interaction with Custom GPT. This method relies on user cooperation and accuracy.

---

<div class="post-metadata">

**Author:** ![matcha72](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/matcha72/32/4667_2.png) [@matcha72](https://community.openai.com/u/matcha72)\
**Post date:** [December 27, 2023, 3:31am UTC](https://community.openai.com/t/matching-gpt-user-to-database-records/572075/9 "2023-12-27T03:31:11Z")

</div>

Yes, you can add Ouath2 in any Custom GPT and collect user emails

---

<div class="post-metadata">

**Author:** ![mdyildirim](https://avatars.discourse-cdn.com/v4/letter/m/34f0e0/32.png) [@mdyildirim](https://community.openai.com/u/mdyildirim)\
**Post date:** [December 29, 2023, 7:36pm UTC](https://community.openai.com/t/matching-gpt-user-to-database-records/572075/10 "2023-12-29T19:36:50Z")

</div>

For those who are looking for a similar solution: I used user input idea. User enters their username, and then I pass it to the API using instructions (simply talk to AI to configure it that way).
