0

Create zia people enrichment

by
Published Oct 17, 2025
Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Create zia people enrichment
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  _module: string | undefined,
12
  record_id: string | undefined,
13
  body: {
14
    __zia_people_enrichment: {
15
      created_time: string;
16
      id: string;
17
      created_by: { name: string; id: string };
18
      status: string;
19
      enriched_data: {
20
        website?: string;
21
        email_infos?: { type: string; email: string }[];
22
        gender?: string;
23
        company_info?: {
24
          name: string;
25
          industries: { name?: string; description?: string }[];
26
          experiences: {
27
            end_date: string;
28
            company_name: string;
29
            title: string;
30
            start_date: string;
31
            primary: false | true;
32
          }[];
33
        };
34
        last_name?: string;
35
        educations?: {}[];
36
        middle_name?: string;
37
        skills?: {}[];
38
        other_contacts?: string[];
39
        address_list_info?: {
40
          continent: string;
41
          country: string;
42
          name: string;
43
          region: string;
44
          primary: false | true;
45
        }[];
46
        primary_address_info?: {
47
          continent: string;
48
          country: string;
49
          name: string;
50
          region: string;
51
          primary: false | true;
52
        };
53
        name?: string;
54
        secondary_contact?: string;
55
        primary_email?: string;
56
        designation?: string;
57
        id?: string;
58
        interests?: {}[];
59
        first_name?: string;
60
        primary_contact?: string;
61
        social_media?: { media_type: string; media_url: string[] }[];
62
      };
63
      enrich_based_on: {
64
        social?: { twitter?: string; facebook?: string; linkedin?: string };
65
        name?: string;
66
        company?: { website?: string; name?: string };
67
        email: string;
68
      };
69
    }[];
70
  },
71
) {
72
  const url = new URL(`https://zohoapis.com/crm/v8/__zia_people_enrichment`);
73
  for (const [k, v] of [
74
    ["module", _module],
75
    ["record_id", record_id],
76
  ]) {
77
    if (v !== undefined && v !== "" && k !== undefined) {
78
      url.searchParams.append(k, v);
79
    }
80
  }
81
  const response = await fetch(url, {
82
    method: "POST",
83
    headers: {
84
      "Content-Type": "application/json",
85
      Authorization: "Zoho-oauthtoken " + auth.token,
86
    },
87
    body: JSON.stringify(body),
88
  });
89
  if (!response.ok) {
90
    const text = await response.text();
91
    throw new Error(`${response.status} ${text}`);
92
  }
93
  return await response.json();
94
}
95