File size: 3,361 Bytes
93ed4be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import gradio as gr
import pandas as pd

# Function to generate email
def generate_email(recipient_name, recipient_role, company_name, industry):
    return (f"Hello {recipient_name},\n\n"
            f"I hope this email finds you well. My name is Niket, and I'm reaching out to you regarding opportunities at {company_name} in the {industry} sector. "
            "I believe we could explore potential collaboration. Would you be available for a coffee chat next week?\n\n"
            "Looking forward to hearing from you!\n\n"
            "Best,\nNiket")

# Function to save user profile to Excel
def save_user_profile(industry, target_audience, personal_info):
    try:
        df = pd.read_excel("user_profiles.xlsx")
    except FileNotFoundError:
        df = pd.DataFrame(columns=["Industry", "Target Audience", "Personal Info"])
    
    new_profile = pd.DataFrame({
        "Industry": [industry],
        "Target Audience": [target_audience],
        "Personal Info": [personal_info]
    })
    
    df = pd.concat([df, new_profile], ignore_index=True)
    df.to_excel("user_profiles.xlsx", index=False)

# Placeholder function for connecting to email client
def connect_email_client(email_service):
    return f"Connected to {email_service} successfully!"

# Placeholder function for analytics
def get_analytics():
    return "Analytics data: Open rates, response rates, conversion metrics..."

# Gradio UI
with gr.Blocks() as demo:
    gr.Markdown("# EmailGenie - Your AI Email Generator")
    
    # User Profile Setup
    gr.Markdown("### User Profile Setup")
    industry = gr.Textbox(label="Industry", placeholder="Enter your industry")
    target_audience = gr.Textbox(label="Target Audience", placeholder="Who are you targeting?")
    personal_info = gr.Textbox(label="Personal Info", placeholder="Any relevant personal info")
    save_button = gr.Button("Save Profile")
    save_button.click(fn=save_user_profile, inputs=[industry, target_audience, personal_info])
    
    # Email Generation Section
    gr.Markdown("### Generate Your Email")
    recipient_name = gr.Textbox(label="Recipient's Name", placeholder="Enter the recipient's name")
    recipient_role = gr.Textbox(label="Recipient's Role", placeholder="Enter the recipient's role")
    company_name = gr.Textbox(label="Company Name", placeholder="Enter the company name")
    output = gr.Textbox(label="Generated Email", interactive=False)
    
    generate_button = gr.Button("Generate Email")
    generate_button.click(fn=generate_email, inputs=[recipient_name, recipient_role, company_name, industry], outputs=output)
    
    # Connect Email Client Section
    gr.Markdown("### Connect Email Client")
    email_service = gr.Dropdown(label="Select Email Client", choices=["SendGrid", "Resend"])
    connect_button = gr.Button("Connect Email Client")
    connect_output = gr.Textbox(label="Connection Status", interactive=False)  # Create output component
    
    connect_button.click(fn=connect_email_client, inputs=[email_service], outputs=connect_output)  # Updated outputs

    # Analytics Dashboard Section
    gr.Markdown("### Email Analytics")
    analytics_button = gr.Button("Get Analytics")
    analytics_output = gr.Textbox(label="Analytics Output", interactive=False)
    analytics_button.click(fn=get_analytics, inputs=[], outputs=analytics_output)

demo.launch()