Create Contact ( hubspot)
One script reply has been approved by the moderators Verified

Created by maximespengesys 360 days ago Viewed 71 times 0 Points

No comments yet

Login to be able to comment
Points: 0
deno
One script reply has been approved by the moderators
Ap­pro­ved
import * as wmill from "https://deno.land/x/windmill@v1.85.0/mod.ts"
import { removeObjectEmptyFields } from "https://deno.land/x/windmill_helpers@v1.0.0/mod.ts"
import { Client } from "npm:@hubspot/api-client@^8.1.0"

export async function main(
  auth: wmill.Resource<"hubspot">,
  company?: string,
  email?: string,
  firstname?: string,
  lastname?: string,
  phone?: string,
  website?: string
) {
  const client = new Client({
    accessToken: auth.token
  })
  const properties = removeObjectEmptyFields({
    company,
    email,
    firstname,
    lastname,
    phone,
    website
  })
  try {
    return await client.crm.contacts.basicApi.create({ properties });
  } catch (e) {
    throw Error(`
      ${e.code} - ${e.body.category}\n
      Message: ${e.body.message}\n
      Correlation ID: ${e.body.correlationId}
    `)
  }
}

Submitted by adam186 178 days ago

Edited 59 days ago

No comments yet

Login to be able to comment