New Zapier Training
/**
* @param {{inputData: InputData}}
*/
export default async function main({inputData}) {
// Construct the request body with the provided details
const requestBody = {
customer: {
first_name: inputData.firstName || '',
last_name: inputData.lastName || '',
email: inputData.email || '',
mobile_number: inputData.phoneNumber || '',
lead_source: inputData.leadSource || '',
notes: inputData.notes || '',
addresses: [
{
street: inputData.street || '',
city: inputData.city || '',
state: inputData.state || '',
zip: inputData.zip || ''
}
]
},
lead_source: inputData.leadSource || ''
};
// Make a POST request to create a lead in Housecall Pro
const response = await fetch('https://api.housecallpro.com/leads', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer YOUR ZAPIER API'
},
body: JSON.stringify(requestBody)
});
// Check if the response is successful
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
throw new Error(`API Error: ${response.status} - ${JSON.stringify(errorData)}`);
}
// Return the response data
const responseData = await response.json();
return { result: responseData };
}
0
6 comments
Brad Elias
1
New Zapier Training
Sublimity Ads Academy
skool.com/sublimity-ads-academy
A network of home service business owners building, testing, and scaling their own meta ads together!
Leaderboard (30-day)
Powered by