Skip to content

NoteLegend/Email-Template-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Email Template Generator

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

1. Clone the Repository

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

2. Set Up the OpenAI API Key

To generate email templates using the OpenAI API, you'll need to use your own API key. Follow these steps:

Get your OpenAI API key:

Sign up at OpenAI and get an API key.

Store the API key in your environment variables:

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

Make sure the backend uses this key for API requests

(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.

3. Running the Project Locally

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:

Install Dependencies:

In your project directory, run the following commands to install the required dependencies:

bash Copy code npm install dotenv node-fetch

Create the .env file:

Add your OpenAI API key as mentioned above.

Start the server:

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 the HTML file in your browser:

Open index.html in your browser to use the email generator.

Without a Backend (Pure Frontend):

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.

4. How to Use the Email Template Generator

Once the project is running:

Select the Email Category:

Choose from categories such as "Professional," "Personal," "Marketing," etc.

Choose the Tone:

Select a tone such as "Formal," "Casual," or "Neutral."

Enter the Recipient and Sender Details:

Type in the recipient's name, sender's name, email subject, and the purpose of the email.

Click "Generate Template":

Click the "Generate Template" button to generate the email based on your input.

Copy or Download the Email:

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.

5. Project Structure

/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

6. Contributing

If you would like to contribute to this project, feel free to fork the repository and create a pull request with your changes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published