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
/* | |
* This code snippet first gets a reference to the contacts postal code. Then it checks a series of arrays for the value. Each | |
* array represents a reps territory or region. When a match is found we assign the HubSpot Owner ID value to a variable and | |
* pass this back to the workflow using the callback object. You are then able to copy this value into the "HubSpot Owner" | |
* property. | |
/ | |
exports.main = async (event, callback) => { | |
// Store contact postal code in variable | |
const zip = event.inputFields['zip']; |
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 = async (event, callback) => { | |
let lineItemNames = []; | |
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
/* | |
* Overview: This code takes the most recently enrolled deal and using the associated company ID obtains the close amount of the most recently closed deal. | |
* It then passes this data back to the workflow which is copied toa property value and we can use this to calculate the upsell value. | |
*/ | |
const hubspot = require('@hubspot/api-client'); | |
exports.main = async (event, callback) => { | |
let companyId, recentDealClosedAmount; // Variables will be used later |
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
/* | |
* Overview: This code looks at all line items associated with a deal. It then updates a multiple checkbox property for the associated company so we can store properties at a company level. | |
* This allows us to quickly and easily view products when viewing a company record, segment companies for account based selling and use company workflows to set a "best next product". | |
* The "best next product" represents the most appropriate product to cross sell based on the current products associated with a company. | |
*/ | |
//1. Import HubSpot Client Library. | |
const hubspot = require('@hubspot/api-client'); | |
//2. Function houses our logic. |
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 libraries | |
const hubspot = require('@hubspot/api-client'); | |
const axios = require('axios'); | |
exports.main = async (event, callback) => { | |
//2. Store threadID in variable, we'll use this to pull information | |
const threadID = event.inputFields['hs_thread_id']; | |
//3. Make a request to the conversations API to retrieve text - https://developers.hubspot.com/docs/api/conversations/conversations |
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 1: Connect to a MySQL Database using NodeJS. Check to see if a record exists that matches the email address of the currently enrolled contact. | |
If they do exist, we do nothing. If they do not exist we add a record to the database. | |
*/ | |
//1. Include the mysql node library | |
const mysql = require('mysql'); | |
exports.main = async (event, callback) => { |
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
/* | |
Operations Hub Workshop #3: Workflow 1 Code | |
This code is used to generate a random number that will be assigned to anyone who joins our referral program. | |
*/ | |
//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) => { |
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 = async (event, callback) => { | |
const fname = event.inputFields['firstname']; | |
const lname = event.inputFields['lastname']; | |
const plus1FirstName = event.inputFields['plus_1_first_name']; | |
const plus1LastName = event.inputFields['plus_1_last_name']; | |
const plus1EmailAddress = event.inputFields['plus_1_email_address']; |
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 1: Make a HTTP Request to Kickbox Verification API using NodeJS request. */ | |
//1. Import libraries, in this instance "request" to make HTTP requests | |
const request = require('request') | |
exports.main = async (event, callback) => { | |
//2. Define variables to store data | |
var role, free, disposable, sendex, result, reason; // We will use these later on when data is returned from Kickbox | |
const email = event.inputFields['email']; // We store the contact email in a variable and will query Kickbox |
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 request = require('request'); | |
exports.main = async (event, callback) => { | |
//1. Store the company domain in a variable | |
var companyDomain = event.inputFields['domain']; | |
var domainAlias, tech, subIndustry, legalName; | |
//2. Configure request to Clearbit Discovery API | |
var options = { |