Hubspot integration

Many of our users use Hubspot, and often they want to be able to interact with Hubspot remotely. Text Blaze's urlload and urlsend commands make it easy to interact with other systems directly from snippets.

text blaze hubspot integration - Watch Video

This is not an exhaustive document of all the ways you can interact with Hubspot using Text Blaze. Some simpler ways to interact with Hubspot using Text Blaze includes:

Hubspot supports private app access tokens, which these snippets use. Follow the linked instructions to create your private app and retrieve your API key. These snippets need the crm.objects.contacts.read and crm.objects.contacts.write scopes.

To use these snippets, you must create your own API token and then update the {token} variable in each snippet.

Retrieve Hubspot Contact properties

This snippet will retrieve Hubspot Contact properties. Search by email address to find the matching Hubspot contact. This snippet is configured to retrieve some standard properties (like name and state), but it can retrieve custom properties as well (like administrator status).

{note}Enter email to look up in Hubspot: {formtext: default=bh@hubspot.com; name=email}{endnote: trim=left}
{if: results="???" or iserror(results)}{error: Enter an email address that matches a contact in Hubspot}{else}Hey {=first},

I'm the Customer Success Manager for {=company} and I'm reaching out about your use of our Product. I'd love to connect with you about your use-case. I know you're based in {=state} -- I'm in WA, so it shouldn't be too hard to find a time we could connect. What works well for you?
{if: admin=="true"}
I also see that you're an administrator of your plan. I'd love to get feedback from you about the reporting enhancements that we rolled out recently. As an administrator, you have unique perspective on those features.{endif: trim=left}

Thanks!
Your Name
{endif}
{note: preview=no; trim=yes}{token="REPLACE_ME_WITH_YOUR_TOKEN"}
{urlload: https://api.hubapi.com/contacts/v1/contact/email/{=email}/profile; method=GET; headers=Authorization: Bearer {=token}; done=(res) -> ["results": catch(fromJSON(res)["properties"], "???")]}
Retrieved first name: {first=results["firstname"]["value"]}
Retrieved company name: {company=results["company"]["value"]}
Retrieved state location: {state=results["state"]["value"]}
Are they an administrator? {admin=results["administrator"]["value"]}
{endnote: trim=yes}

Create a Contact from anywhere

This snippet lets you create a contact in Hubspot from anywhere. It includes some basic Hubspot fields to complete when creating your contact. You can customize this to include any required fields you'd like to include upon creation.

{note}
Email: {formtext: name=email} {if: not contains(email, "@") AND not contains(email, ".")}{error: Enter a valid email address; block=yes}{endif}
First Name: {formtext: name=firstname}
Last Name: {formtext: name=lastname}
Company: {formtext: name=company}
Phone Number (10 digits): {formtext: name=phone} {if: len(phone)<>10 OR not testregex(phone, "\d{10}")}{error: Enter a valid 10 digit phone number; block=yes}{endif}
{if: (email<>"" AND firstname<>"" AND lastname<>"" AND company<>"" AND len(phone)=10 AND testregex(phone, "\d{10}"))}Click insert to create contact{note: preview=no}{token="REPLACE_ME_WITH_YOUR_TOKEN"}
{urlsend: https://api.hubapi.com/contacts/v1/contact; method=POST; headers=Authorization: Bearer {=token}, Content-Type:application/json; body={=body}}
{body={
"properties": [
{
"property": "email",
"value": "{=email}"
},
{
"property": "firstname",
"value": "{=firstname}"
},
{
"property": "lastname",
"value": "{=lastname}"
},{
"property": "company",
"value": "{=company}"
},{
"property": "phone",
"value": "{=phone}"
}]
}}{endnote}{else}Not ready to create contact - please complete all fields{endif}{endnote}

Create a Contact from LinkedIn

This is the same as the previous snippet, except it can automatically retrieve the first name, last name, and company name from a LinkedIn profile page. Those values are automatically placed into the form fields when being used, but are still editable before saving.

{note}
Email: {formtext: name=email} {if: not contains(email, "@") AND not contains(email, ".")}{error: Enter a valid email address; block=yes}{endif}
First Name: {formtext: name=firstname; default={=split({site: text; selector=.text-heading-xlarge}, " ")[1]}}
Last Name: {formtext: name=lastname; default={=split({site: text; selector=.text-heading-xlarge}, " ")[2]}}
Company: {formtext: name=company; default={site: text; selector=.inline-show-more-text.inline}}
Phone Number (10 digits): {formtext: name=phone} {if: len(phone)<>10 OR not testregex(phone, "\d{10}")}{error: Enter a valid 10 digit phone number; block=yes}{endif}
{if: (email<>"" AND firstname<>"" AND lastname<>"" AND company<>"" AND len(phone)=10 AND testregex(phone, "\d{10}"))}Click insert to create contact{note: preview=no}{token="REPLACE_ME_WITH_YOUR_TOKEN"}
{urlsend: https://api.hubapi.com/contacts/v1/contact; method=POST; headers=Authorization: Bearer {=token}, Content-Type:application/json; body={=body}}
{body={
"properties": [
{
"property": "email",
"value": "{=email}"
},
{
"property": "firstname",
"value": "{=firstname}"
},
{
"property": "lastname",
"value": "{=lastname}"
},{
"property": "company",
"value": "{=company}"
},{
"property": "phone",
"value": "{=phone}"
}]
}}{endnote}{else}Not ready to create contact - please complete all fields{endif}{endnote}

Reach out if you want to use these!

While these snippets should be simple to start using with your own API key, we're more than happy to help you get these working.

Reply here if you'd like some assistance, or reach out to support@blaze.today for hands-on help.

Let us know other ways you'd want Text Blaze to integrate with Hubspot

If you want Text Blaze to do more with Hubspot than what you see here, reply to this thread and let us know what you'd like it to do. We'll explore the possibility and help you build it!

3 Likes