This project is a web-based Email Template Generator that allows users to generate personalized email templates based on various input categories, tone, recipient, sender, subject, and purpose. The generated email template can be copied to the clipboard or downloaded as a .txt file.
Features: Choose from different categories and tones. Input recipient, sender, subject, and purpose for the email. Generate email templates dynamically using the OpenAI API. Copy generated email content to the clipboard. Download the generated email as a .txt file. How to Set Up and Run the Project
First, clone the repository to your local machine:
bash Copy code
git clone https://github.com/yourusername/email-template-generator.git cd email-template-generator
To generate email templates using the OpenAI API, you'll need to use your own API key. Follow these steps:
Sign up at OpenAI and get an API key.
On your local machine, create a .env file in the root directory of your project and add your OpenAI API key:
makefile Copy code OPENAI_API_KEY=your-api-key-here
(if you're using a Node.js backend as mentioned in the previous discussion). Alternatively, if you're not running a backend server, you can skip this step and focus on the frontend part.
Since this project uses HTML, CSS, and JavaScript, it can run entirely in the browser without needing a backend server. However, if you are making API requests to OpenAI, a server is required.
If you have a backend server: Follow these steps to set up and run the backend (Node.js) server:
In your project directory, run the following commands to install the required dependencies:
bash Copy code npm install dotenv node-fetch
Add your OpenAI API key as mentioned above.
If you're using a Node.js backend to handle API requests, start the server:
bash Copy code node server.js The server will be running at http://localhost:3000.
Open index.html in your browser to use the email generator.
Open the HTML file in your browser directly: Just open the index.html file in your browser (no backend needed). The email generation functionality will work based on static inputs. You can replace the generateEmail() function to hardcode email responses if you don't need dynamic generation from OpenAI.
Once the project is running:
Choose from categories such as "Professional," "Personal," "Marketing," etc.
Select a tone such as "Formal," "Casual," or "Neutral."
Type in the recipient's name, sender's name, email subject, and the purpose of the email.
Click the "Generate Template" button to generate the email based on your input.
After the email is generated, you can: Click "Copy to Clipboard" to copy the email content. Click "Download" to download the generated email as a .txt file.
/email-template-generator ├── index.html # The main HTML file ├── style.css # The styling for the email generator ├── script.js # The JavaScript logic for email generation ├── .env # Store your OpenAI API key here (for backend) ├── server.js (Optional) # Backend server code (Node.js) to make OpenAI API requests └── README.md # This readme file
If you would like to contribute to this project, feel free to fork the repository and create a pull request with your changes.