File size: 4,449 Bytes
25feb32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b70e97f
 
25feb32
 
f0f7088
 
 
b70e97f
 
25feb32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b65363b
 
 
b70e97f
 
b65363b
 
 
 
 
25feb32
 
b70e97f
 
 
 
 
 
 
 
 
 
 
 
 
 
25feb32
 
b70e97f
 
 
25feb32
5e898dd
c6c08f0
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Gradio interface
from functionality.funct import convert_json_to_files
import gradio as gr


# Function to validate if inputs are filled
def is_input_valid(api_key, json_data):
    return bool(api_key.strip()) and bool(json_data.strip())


# Main function to process the inputs
def process_inputs(api_key, json_data):
    # Replace with actual processing logic if needed
    return convert_json_to_files(api_key, json_data)


# Interface setup
with gr.Blocks() as iface:
    gr.Markdown(
        """
    # Leads Fetcher
    This tool allows you to input JSON data and fetch the corresponding leads. 
    Make sure to enter a valid API Key and your JSON data to get the CSV preview and download the converted Excel file.  

    **[NOTE]**: If you are using free plan of Apollo it will allow only 5 pages of fetching per request, total 125 Leads per request.
    """
    )

    with gr.Row():
        with gr.Column():
            api_key_input = gr.Textbox(
                label="API Key for Apollo",
                placeholder="Enter your API key here...",
                lines=1,
            )

            json_input = gr.Textbox(
                label="Input JSON Data", placeholder="Enter JSON data here...", lines=10
            )
            submit_btn = gr.Button("Submit")

        with gr.Column():
            csv_output = gr.Dataframe(label="CSV Preview")
            file_output = gr.File(label="Download Excel File")

    # Control button state
    def update_submit_state(api_key, json_data):
        return gr.update(interactive=is_input_valid(api_key, json_data))

    api_key_input.change(
        fn=update_submit_state, inputs=[api_key_input, json_input], outputs=submit_btn
    )
    json_input.change(
        fn=update_submit_state, inputs=[api_key_input, json_input], outputs=submit_btn
    )

    submit_btn.click(
        fn=process_inputs,
        inputs=[api_key_input, json_input],
        outputs=[csv_output, file_output],
    )

    examples = gr.Examples(
        examples=[
            [
                "OykhjTWxqLFmU4fXgwqK5A",
                '{"page":1,"sort_by_field":"[none]","sort_ascending":false,"contact_email_status_v2":["likely_to_engage","verified"],"person_department_or_subdepartments":["master_sales"],"person_locations":["United States"],"person_seniorities":["director"],"included_organization_keyword_fields":["tags","name","social_media_description","seo_description"],"q_organization_keyword_tags":["app development"],"organization_num_employees_ranges":["101,200"],"display_mode":"explorer_mode","per_page":25,"open_factor_names":[],"num_fetch_result":1,"context":"people-index-page","show_suggestions":false,"include_account_engagement_stats":false,"include_contact_engagement_stats":false,"finder_version":2,"ui_finder_random_seed":"6gfkmmnjsqn","typed_custom_fields":[],"cacheKey":1735714146736}',
            ]
        ],
        inputs=[api_key_input, json_input],
    )

    gr.Markdown("<hr>")

    gr.Markdown(
        """
   ## How to get JSON input ##

    1. Go to the Apollo filtered link (for example):
    [Apollo Filtered Link](https://app.apollo.io/#/people?page=1&contactEmailStatusV2[]=likely_to_engage&contactEmailStatusV2[]=verified&prospectedByCurrentTeam[]=no&sortByField=%5Bnone%5D&sortAscending=false&includedOrganizationKeywordFields[]=tags&includedOrganizationKeywordFields[]=name&organizationIndustryTagIds[]=5567cd4773696439b10b0000&personLocations[]=United%20States&organizationNumEmployeesRanges[]=21%2C50&organizationNumEmployeesRanges[]=51%2C100&organizationNumEmployeesRanges[]=101%2C200&organizationNumEmployeesRanges[]=201%2C500&excludedOrganizationKeywordFields[]=tags&excludedOrganizationKeywordFields[]=name&excludedOrganizationKeywordFields[]=social_media_description&excludedOrganizationKeywordFields[]=seo_description&personDepartmentOrSubdepartments[]=master_human_resources&personSeniorities[]=entry&personSeniorities[]=senior&personSeniorities[]=manager&personSeniorities[]=director&personSeniorities[]=head&personSeniorities[]=vp&personSeniorities[]=c_suite&personSeniorities[]=partner)

    2. Open **Inspect Element** in your browser and navigate to the **Network** tab.

    3. Click on the first **"search"** entry in the **Name** column.

    4. Click on **"View Parsed"** and copy the entire payload.

    ---

    ![Leads Fetcher Demo](https://i.ibb.co/2qwk2vd/ezgif-2-93235bbbb8.gif)

    """
    )


iface.launch(share=True,debug=True)