Contact Card Extractor Using AI (GPT3)

Sep 1, 2022

Contact Card Extractor using AI

I wanted to exercise my Full-Stack AI-enabled SaaS muscles, so I came up with this little project to scratch that itch. The premise is simple: personal emails always have signatures at the bottom and it could be useful to automatically generate contact cards for people that send me an email.

In this article I’ll walk through the different steps and tech I used in the process. If people are interested, I can go more in depth in a future post, but I’ll keep in general for now.

Define Scope of Project

This always takes some time to think about and refine, but I eventually landed on this for a resulting workflow: when I receive an email with a contact I want to have, I want to forward it to another address, and receive the contact card in return. This way anybody could use this service, and the only tech they need to know is how to forward an email.

Steps to Completion

  1. Prototyping / Viability

  2. Architect AWS Services

  3. Spin Up SST Project

  4. Build Function Logic

  5. Register Domain

  6. Turn it On and Try it Out

Prototyping / Viability

First I needed to make sure this will actually work pretty well. Can I take an email and extract contact information accurately? What model will I use and how will I ultimately process the text?

Nothing is better these days for rapid NLP prototyping than OpenAI’s text-davinci-002 model. I copied and pasted an email I received from someone the other day trying to market outsourced developers.

That was easy… this thing never ceases to amaze me

Architect AWS Services

This is the final flow I decided on is something similar to this diagram from this article.

The incoming email is the forwarded email that I want the contact info from. SES will pick that up, and upon receiving it, will trigger the email to be stored in S3. Then I have a Lambda function that will pick up that email, parse it, call GPT-3 and return a contact card file. Finally, SES will reply to that forwarded email with the contact card attached.

Spin up SST Project

As much as I can, I try to make all of the AWS infrastructure from code, and the guys over at SST know what they’re doing. With a few commands, I’ve got a boilerplate that I can begin to build off of.

Build Function Logic

Finally I can start to write some code. I had to figure out how to build a vCard (the name for contact card files, who knew?) but everything else I had basically done before.

Register Domain

I had to register a domain so I could send and receive emails from it - so I decided on a simple name and paid a few bucks for one using Route53.

In order to use this domain with SES, I had to set up DKIM for it in the SES console and verify the email address.

Turn it On and Try it Out

Once I finished the function logic, I created an SES rule to trigger my lambdas on receipt of email. Now whenever an email is sent to that domain, it will run through that architecture I set up earlier, and eventually send an email back.

Here’s the email I forwarded:

And the response:

And here’s the contact card it returned!!

I blacked out the email address I used for this project to keep from needing to set up rate throttling. If you read this far down then you might think this is a cool project and might like to try it out for yourself - if so I’ll be happy to send you the address: just shoot me an email at

The next steps for the project are incremental improvements on the backend functions - handling longer and harder to parse emails. There are definitely some interesting and challenging cases to look into.