GPT + Email + Notion integration question

I’ve created a scenario like this:

  1. Make pulls all new emails and sends them to GPT3.5.

  2. GPT is then supposed to read the text of the email and pull out the company name of the incoming lead.

  3. We search our Notion database to see if the company name exists. If so, we update the database. If not, we create a new database entry.

The problem is that step #2 works 90% of the time, but sometimes it parses it differently (example: Acme Company vs The Acme Company or TheAcmeCompany) or sometimes it returns (ie. "The company name is The Acme Company.)

Our GPT prompt looks like this:

Extract ONLY the brand/company name from this email chain. It's NOT Gmail. Return ONLY the brand name, nothing else and no other text

Questions:

  1. Is there a way I can do a “fuzzy” search to see if there is a company name in the Notion DB that is similar to the one GPT pulled out so we don’t create duplicate entries?

  2. Is there a way to make sure GPT will generally return the same info every time it’s an email from the same company?

Bump. I’m trying to do a similar thing. Any progress?

I wondered if you could aggregate and dump your Notion database as a JSON object → plain text and have OpenAI model parse it and 'Determine the most relevant existing record/page based on the exisiting database {Notion DB} and the email we just received."

You could then update that page, or create a new one if no good match found. Essentially use OpenAI to do the fuzzy part.

Could be quite token-intensive though.