Created
September 22, 2022 16:15
-
-
Save HubSpotHanevold/9d69f6b7210a8380a7cdf2b6c4758ee7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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) => { | |
const email = event.inputFields['email']; | |
let domain = email.split('@')[1]; | |
let username = email.split('@')[0]; | |
var options = { | |
'method': 'GET', | |
'url': 'https://api.hubapi.com/hubdb/api/v2/tables/5486243/rows?name=' + domain, | |
'headers': { | |
'Authorization': 'Bearer ' + process.env.HUBDBKEY | |
} | |
}; | |
request(options, function (error, response) { | |
if (error) throw new Error(error); | |
const obj = JSON.parse(response.body); | |
let corrected_domain = obj.objects[0].values['2']; | |
let corrected_email = username + '@' + corrected_domain; | |
callback({ | |
outputFields: { | |
former_email: email, | |
corrected_domain: corrected_domain, | |
corrected_email: corrected_email | |
} | |
}); | |
}); | |
} |
Linked CSV of common domain misspellings for hubdb table.
Link to CSV
Preview of custom coded action output:
Link to Preview
Create a hubdb table with the domain misspellings and corrected domains.
Create a list of contacts with domain misspellings (filter by email contains misspelling)
Create a workflow with trigger being member of said list ^
Custom coded action that splits username from domain, looks up misspelled domain in hubdb, then returns corrected domain
Append username back to corrected domain and output the corrected email
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note, you have to change out the ID of the table in the request. Also, your secret token may need to be renamed.