This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import the Hubspot NodeJS Client Library - this will allow us to use the HubSpot APIs | |
const hubspot = require('@hubspot/api-client'); | |
/* | |
This function is called when the custom code action is executed. It takes 2 arguements. The first is the event object which contains information on the currently enrolled object. | |
The second is the callback function which is used to pass data back to the workflow. | |
*/ | |
exports.main = (event, callback) => { | |
// Instantiate a new HubSpot API client using the HAPI key (secret) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Example 2: Make a HTTP Request to Kickbox Email Verification API using NodeJS axios */ | |
//1. Import libraries, in this instance "axios" to make HTTP requests | |
const axios = require('axios'); | |
exports.main = async (event, callback) => { | |
//2. Store contact email in variable | |
var email = event.inputFields['email']; | |
//3. Configure and Make our HTTP request to Kickbox Email Verification API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios'); | |
axios.defaults.headers.common['authorization'] = `Bearer ${process.env.HUBSPOTTOKEN}`; | |
axios.defaults.headers.common['Content-Type'] = `application/json`; | |
axios.defaults.headers.put['Content-Type'] = `application/json`; | |
exports.main = async (event) => { | |
const partner_id = event.inputFields['partner_id']; | |
const partnerObjectId = await getPartner(partner_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import HubSpot Client Library and instantiate client with private app token | |
const hubspot = require('@hubspot/api-client'); | |
const hubspotClient = new hubspot.Client({ | |
accessToken: process.env.HUBSPOTTOKEN // Access token associated with your private app (also be sure to include token in secrets) | |
}); | |
// Helper function to get the associated Object ID of a specified Object Type | |
async function getAssociatedObjectId(objectType, objectId, toObjectType) { | |
let obj = await hubspotClient.crm.objects.associationsApi.getAll(objectType, objectId, toObjectType); | |
return obj.results[0].id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hubspot = require('@hubspot/api-client'); | |
exports.main = (event, callback) => { | |
const hubspotClient = new hubspot.Client({ | |
apiKey: process.env.HAPIKEY | |
}); | |
hubspotClient.crm.contacts.basicApi.getById(event.object.objectId, ["full_name"]) | |
.then(results => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1. Import required libaries | |
const Promise = require("bluebird"); // Javascript Promise Library | |
const randomNumber = require("random-number-csprng"); // Javascript Random Number Generator | |
exports.main = (event, callback) => { | |
//2. Using a Promise, we first try to generate a random number | |
Promise.try(function() { | |
return randomNumber(10000, 50000); // Generate Random Number between a defined range | |
}).then(function(number) { // When the number is successfully generated we do this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import required libraries | |
const hubspot = require('@hubspot/api-client'); | |
const mysql = require('mysql'); | |
// This function is called when the custom coded action is executed | |
exports.main = (event, callback) => { | |
// Create a new instance of the HubSpot API Client - we need this to interact with the CRM APIs to retrieve information relating to the currently enrolled record | |
const hubspotClient = new hubspot.Client({ | |
apiKey: process.env.HAPIKEY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import the Hubspot NodeJS Client Library - this will allow us to use the HubSpot APIs | |
const hubspot = require('@hubspot/api-client'); | |
//Instantiate a new HubSpot API client using an access token (private app) | |
const hubspotClient = new hubspot.Client({ | |
accessToken: process.env.HUBSPOTTOKEN | |
}); | |
// Helper function to associate Company to Contact using HubSpot Client | |
function associateCompanyToContact(companyId, contactId) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import the required libraries - in this instance the HubSpot NodeJS API client | |
const hubspot = require('@hubspot/api-client'); | |
exports.main = (event, callback) => { | |
// Create a new instance of the HubSpot client | |
const hubspotClient = new hubspot.Client({ | |
apiKey: process.env.HAPIKEY | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hubspot = require('@hubspot/api-client'); | |
exports.main = (event, callback) => { | |
const hubspotClient = new hubspot.Client({ | |
apiKey: process.env.HAPIKEY | |
}); | |
//1) Get the enrolled deal - referrer_id property value | |
hubspotClient.crm.contacts.basicApi.getById(event.object.objectId, ["referrer"]) |
NewerOlder