Demos

HubSpot contacts analytics

13min
synopsis this is a proof of concept on how the procesio platform can be used to integrate with hubspot, fetch a contact list, iterate through it, make web searches based on a certain property of the contact to extract useful information and close the loop by posting an engagement back in hubspot as a note containing a list of links to relevant articles along with a weighted summary of what topics are addressed in each article what's hubspot? hubspot is a cloud based crm designed to help align sales and marketing teams, foster sales enablement, boost roi, and optimize the inbound marketing strategy of a company in order to generate more qualified leads among its various use cases, the hubspot platform allows sales teams to organize a pool of leads or potential leads as a list of contacts properties like phone number, email, company name, status, or owner are associated with a contact which helps model the relationship with the client throughout all phases from reaching them to closing the deal in addition, each contact has dedicated sections like notes, tasks, and meetings that represent different types of engagement with that contact for example, the owner wants to keep track of what tasks they have to do regarding a certain contact by creating a task they will remember to follow up with a call or an email and maintain the relationship with the client alive also, notes are useful if one wants to have observations from previous meetings stored in a digital format, not only in a notebook what's the goal? let's say a hubspot user, typically a salesperson, wants to be up to date with all that's going on in the news regarding his contacts by being constantly informed one can have valuable insight into a client's company which might be useful when approaching the contact nowadays news runs fast and it's sometimes hard to keep up with the huge amount of information that's available on the world wide web going through each contact in hubspot and scrolling through the news websites to find out the latest things about them sounds like a time consuming activity what if, instead, you could have the top 3 most relevant articles about each contact aggregated directly in hubspot as notes? maybe you're interested in a certain list of topics and want to read only the articles that are related to health or investments having a classification of each article by topic might seem necessary say you want to skip an article on tesla (one of your contacts is working at this company) that talks about business because you are already knowledgeable about this particular combination just check the next article about tesla which happens to have been identified as approaching the environment subject the examples can go on and on, but the bottom line is how much amount of time can be saved by having well structured insight data enclosed in the list of contacts that you go through day by day data that can be easily tailored at any time to be relevant and up to date integrations before going further we should identify who are the actors in this automated play hubspot you will be needing an hs account preferably a development account for testing purposes (if you already have an hs account, development or otherwise, skip the underlying steps or take a quick read here although you still need a test account if you don't want to mess with your production like environment first) follow this link https //developers hubspot com/get started https //developers hubspot com/get started and choose create app developer account once done with the previous step go to the home page and choose to create a test account (for more info check https //legacydocs hubspot com/docs/faq/how do i create a test account https //legacydocs hubspot com/docs/faq/how do i create a test account ) for api usage you will need an api key in order to make authorized calls so from the top right corner click on the avatar and select profile & preferences then on the left list of settings expand the integrations drop down and select api key and then create one if no active api key available and save it for later newsapi newsapi is a web project that allows users to search the web for news via powerful apis and client libraries for several programming languages the existence of a wide list of search parameters lets you create versatile queries a similar service called newsapi ai has apis oriented towards analytics and one can benefit from analyzing the sentiment of a given text or the extraction of topics from a given article both services are well documented and work based on api keys the caveat is that there are some limitations when using the free plan building the solution with procesio finally, it's time to connect the dots and bring procesio in if hubspot and newsapi are the actors then procesio is the scene, the director, the machinist you get the idea if you are slightly familiar with how procesio works then you can continue reading, otherwise, it will be a bit fuzzy but you can of course go through the procesio documentation starting with the basics, and easily reach a level where you can understand almost any process and then come back the solution evolves around orchestrating four main api calls getcontacts used to read all contacts from hubspot getnews a query based search that returns news about a given contact analytics a gateway to a sub process that runs a sequence of endpoints that will be used to analyze text from articles and summarize the main topics along with their weight in that article; this is mapped into an object which will be validated and formatted for posting in hs by the parent process postnote the call that posts an engagement to hubspot which adds the results in the notes section of a given contact getcontacts first, we want to bring all contacts into the process i used the call api action and configured it according to the hubspot api documentation namely the contacts section hubspot has a limit of 100 contacts per page the scope of this article does not cover scenarios with over 100 contacts in the crm for that, you might need to use a for each loop to iterate through each set of contacts the configuration should include choosing a previously created rest api credential you just need to create a new entry in the credential manager for hubspot api where you set the root of the endpoints you will be using along with the authentication method (api key) and a test endpoint to see that it's working an important note here is that you don't need to mention the authentication method later when using this credential in any of your processes this will be stored in the configuration from the credential manager and taken into account automatically on top of building your request this is what the request looks like just save the body output in a json variable and optionally the status output in an integer variable and start using it you can also test it before in postman or directly in the action with the test action feature there are two methods by which you can save the body output of a request using a json variable using a data model object variable in the second you will have to go to the data models section ➜ create from json (should be visible after expanding the arrow on the right of create data model) ➜ give it a name and then choose editor (json content) radio button that will bring an editor where you can paste the raw json of your expected body output response a data model will be created with the keys and values from that json each approach has its advantages and disadvantages for option 1 you'll need to use a json mapper action and with json path language query your way to what object you need option 2 it is more intuitive since you have your json serialized into an object ultimately it is your choice once the list of contacts is extracted by using the json mapper action then it should be iterated upon using the for each action getnews for complete usage of the endpoint used to fetch news about our contacts check this link similar to the other api call (getcontacts) there is a rest api credential that will drive the call api action and will take care of the authentication which is api key based below is an example of a body response for a news query about mcdonald's returning the 3 most relevant articles from a given day { "status" "ok", "totalresults" 19, "articles" \[ { "source" { "id" null, "name" "the guardian" }, "author" "australian associated press", "title" "new zealand cricket great daniel vettori joins australia's new coaching staff", "description" "\<ul>\<li>former test spinner joins andre borovec in new positions\</li>\<li>pair will begin their roles on next month’s sri lanka tour\</li>\</ul>former new zealand test spinner daniel vettori will make a full time switch to australia’s cricket set up after being …", "url" "https //amp theguardian com/sport/2022/may/24/new zealand cricket great daniel vettori joins australias new coaching staff", "urltoimage" "https //i guim co uk/img/media/338e360d3e12ef3ecf2120f9ac98b53686110f38/0 139 3500 2100/master/3500 jpg?width=1200\&height=630\&quality=85\&auto=format\&fit=crop\&overlay align=bottom%2cleft\&overlay width=100p\&overlay base64=l2ltzy9zdgf0awmvb3zlcmxhexmvdgctzgvmyxvsdc5wbmc\&enable=upscale\&s=2b6431ba8894f79bb87897123eb6d653", "publishedat" "2022 05 24t03 45 05z", "content" "former new zealand test spinner daniel vettori will make a full time switch to australias cricket set up after being appointed as one of andrew mcdonalds two new assistant coaches vettori and victor… \[+1976 chars]" }, { "source" { "id" "axios", "name" "axios" }, "author" "sara fischer", "title" "friendly corporate brands poisoned by politics", "description" "companies that once seemed immune from partisan backlash are seeing their reputations plunge in response to political drama, according to new rankings from the annual axios/harris poll 100 why it matters the findings suggest that companies that are slow to …", "url" "https //www axios com/2022/05/24/axios harris poll 100 corporate brands politics", "urltoimage" "https //images axios com/mqezuwqavmzhwocjeuytjizfvli=/0x0 1920x1080/1366x768/2022/05/20/1653069057732 jpg", "publishedat" "2022 05 24t09 31 03z", "content" "companies that once seemed immune from partisan backlash are seeing their reputations plunge in response to political drama, according to new rankings from the annual axios/harris poll 100 \r\nwhy it … \[+2652 chars]" }, { "source" { "id" null, "name" "the guardian" }, "author" "samantha lock", "title" "russia ukraine war updates moscow to deepen ties with china, lavrov says; west pledges to send more advanced weapons to ukraine – live", "description" "russia’s foreign minister says moscow will only depend on ‘reliable’ countries not beholden to the west; new aid packages include harpoon anti ship missiles to protect ukraine’s coast\<ul>\<li>russian diplomat in geneva resigns over ukraine invasion\</li>\<li>ukr…", "url" "https //www theguardian com/world/live/2022/may/24/russia ukraine war updates moscow to deepen ties with china lavrov says west pledges to send more advanced weapons to ukraine live", "urltoimage" "https //i guim co uk/img/media/e6fa761c65bf417ef381e5abf55198ce364cf280/0 83 8234 4944/master/8234 jpg?width=1200\&height=630\&quality=85\&auto=format\&fit=crop\&overlay align=bottom%2cleft\&overlay width=100p\&overlay base64=l2ltzy9zdgf0awmvb3zlcmxhexmvdgctbgl2zs5wbmc\&enable=upscale\&s=cab92c023cf11bd912d21146da574ed3", "publishedat" "2022 05 24t04 57 37z", "content" "outgoing philippine president rodrigo duterte has sharply criticised russian president vladimir putin for the killings of innocent civilians in ukraine \r\ni kill criminals, i dont kill children and th… \[+7612 chars]" } ] } within the for each block we will process each contact in a series of steps read the company name of the contact and the id of the contact (will be used later to post back in hs in his notes) call the newsapi and fetch the top 3 most relevant articles about that company here we also pass the current day (i e today) as we want fresh news call the analytics sub process and gather some insights on what are the topics from the content of the articles validate the output from the sub process while preparing the received information (list of articles + topic analysis) to be posted back in hs as a note no code can be tricky when dealing with lists, but we can make use of constants (variables with default values e g an integer with the value 0 acting as a counter), the array of list platform actions ( get x element , return list element count ), numerical actions like subtract operation and, of course, decisional action all which combined give control over the list that is being processed analytics there are two reasons why i decided to organize/hide this analytics part (i e from analyzing each article) as a sub process namely because it is complex and no code is in the end about abstraction and because having more than one contact and more than one article per contact brings the no code developer in a for each in for each situation or nested for each at the moment this can only be achieved in procesio by calling a sub process from the main for each that will implement another for each inside as a recap, the analytics sub process receives a list of articles (as urls) relevant for contact and returns another list containing the original articles and some data regarding what the articles are addressing there are two api calls to the analytics endpoints of newsapi categorize and extract article information let's showcase the latter having the text provided by the extract article information call, the categorize endpoint will return a categorization by (news) topics now, all that's needed is a list of connected actions ( to string , string replace , multiply , json mapper , decisional , join , map process data ) which will process and format the raw information postnote we've reached the final api call once the processing is done a variable named "tobeposted" will contain the result in the desired format this variable and the id read in the previous steps from the contact object it's all we need to close the loop and post back to hubspot results it's now time to run the process! and check the results! conclusions a sales use case was implemented fresh and valuable news about each contact from the crm is being aggregated as a note in the contact view once a day new content will be uploaded and displayed in hubspot for the salesperson to browse the format of the aided information can vary and it's not limited to the news link categorization combination instead of using the name of the company as input for the news query one can use the contact name possibilities are multi fold one can make use of sentiment analysis apis or translation apis this is just a proof of concept showing that with procesio you can bridge two complementary tools to simplify the life of the user and why not the whole department's activity going forward, imagination is the only limit!