Skip to content

Instantly share code, notes, and snippets.

View HubSpotHanevold's full-sized avatar

Tyler Hanevold (HubSpot) HubSpotHanevold

View GitHub Profile
// Import the crypto module
const crypto = require('crypto');
exports.main = async (event, callback) => {
try {
// Example: variable from HubSpot workflow input or event
const inputValue = event.inputFields['hs_object_id'];
// Create a SHA-256 hash
const hash = crypto
// Define your webhook URL
const webhookUrl = 'https://webhook.site/3e9fcebf-f527-4351-aae4-bfa5c14901af';
// Define the payload you want to send
const payload = {
message: 'Hello from Airtable!',
timestamp: new Date().toISOString()
};
// Send the POST request
const axios = require('axios');
// PUT THE FROMS/TOS IN THIS DATA VARIABLE
let data = JSON.stringify({
"inputs": [
{
"from": {
"id": "40715675193"
},
"to": {
const axios = require('axios');
exports.main = async (event, callback) => {
const hs_object_id = event.inputFields['hs_object_id'];
let data = JSON.stringify({
"filterGroups": [
{
"filters": [
{
{% set this_time = request.query_dict.this_time %}
{% set todays_time = unixtimestamp(datetime.now()) %}
{% if todays_time - this_time > 172800000 %}
<h2>
LINK EXPIRED
</h2>
<p>The value of this_time is: {{ this_time }}</p>
<p>
exports.main = async (event, callback) => {
/*****
Use inputs to get data from any action in your workflow and use it in your code instead of having to use the HubSpot API.
*****/
const callNote = event.inputFields['hs_call_body'];
// Step 1: Split the string into key-value pairs
const keyValuePairs = callNote.split(';');
// Step 2: Store values in variables
exports.main = async (event, callback) => {
let state_zips = [
{ "state": "AL", "zip_low": 35004, "zip_high": 36925 },
{ "state": "AK", "zip_low": 99501, "zip_high": 99950 },
{ "state": "AZ", "zip_low": 85001, "zip_high": 86556 },
{ "state": "AR", "zip_low": 71601, "zip_high": 72959 },
{ "state": "CA", "zip_low": 90001, "zip_high": 96162 },
{ "state": "CO", "zip_low": 80001, "zip_high": 81658 },
{ "state": "CT", "zip_low": 6001, "zip_high": 6928 },
{ "state": "DE", "zip_low": 19701, "zip_high": 19980 },
@HubSpotHanevold
HubSpotHanevold / sample.php
Created April 16, 2025 16:33
Sample PHP Curl Forms Submit API
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.hsforms.com/submissions/v3/integration/submit/portalId/formGuid',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
@HubSpotHanevold
HubSpotHanevold / script.js
Last active December 3, 2024 20:00
Validate additional property as email only
<script>
document.addEventListener("DOMContentLoaded", function() {
setTimeout(function() {
const emailInput = document.querySelector('input[name="2-8330456/tour_contact_email"]');
emailInput.addEventListener("input", function() {
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
const parentDiv = emailInput.closest('.input');
let messageDiv = parentDiv.querySelector('.email-error');
@HubSpotHanevold
HubSpotHanevold / script.php
Last active December 3, 2024 16:36
A php script to replicate HubSpot properties created on a standard object and add to a custom object. Only creates non-HubSpot default properties on the new object.
<?php
// PHP SCRIPT TO MOVE PROPERTIES FROM A STANDARD OBJECT TO A CUSOTM OBJECT
// READ ME
// MODIFY THESE VARIABLES BELOW AS YOU SEE FIT (LINES 8-10)
// ALSO MODIFY THE GROUP NAME MAPPINGS BELOW (LINES 53-56)
$authToken = 'ADD_YOUR_TOKEN_HERE';
$standardObject = 'contacts';
$customObjectInternalName = '2-37668321';