Paramail is an AI web app that helps Korean users easily understand and reply to English emails. I developed this project to participate in the first GenAI Hackathon in South Korea and won second place in the competition.
The app is divided into two main functions; creating new emails and replying to emails. Composing a new email is not difficult and can be done with ChatGPT alone, so I focused on the flow of composing a reply email.
When the user enters the English email they received, the translation and analysis process begins. For direct translation, I used the Google Translate API for speed. The email analysis is using the OpenAI GPT-3.5 model.
Prompt engineering
The most challenging aspect of prompt engineering was consistently getting the desired form of response. Even when the temperature of the API was set to 0 and the exact type of response was requested, GPT would sometimes return an unexpected response.
When analysing emails, I prioritised Korean accuracy over speed, so instead of using the Google API, I asked GPT to respond directly in Korean. The problem was that GPT would sometimes ignore the request and reply in English. To minimise this, I gave GPT the role ‘Assistant for Korean email recipients’ in the prompt, and I think it helped.
To make GPT responses usable on the frontend, it is essential to standardize the format. In order to do this, I used a method called the Few-Shot technique, which involves including example questions and answers in the prompts. Through iterative testing, I was able to determine the example emails and the number of them that would minimize the use of tokens while ensuring the stability of the answer format.
Email analysis consists of generating a short summary, a checklist of things the recipient shouldn’t miss, and a list of possible responses based on that.
Rendering UI based on GPT response
To turn the GPT’s response into a user interface, I used Regex to split the text. Again, error handling was important because the GPT response format is not 100% reliable.
Finally, the response email is generated based on the initial email received and the user’s selected or manually entered response. To help the user see the full content of the generated response email, the Google Translate API was used to show a translation.
Technical specifications
The app was built on Next.js and used Supabase Auth and a database. For some UI components like Tab, Dialog, and Popover, Radix UI was used and CSS was done using Tailwind. The credit payment system was built with Supabase and Stripe.