APIs & Integrations

cfrye_1st_page
Participant | Partner
Participant | Partner

API queries to replicate the data in the Productivity widget from the Sales dashboard

Hello

 

I'm trying to use the Engagements API to pull the data from Productivity widget from the Sales Dashboard so I can replicate this widget within Klipfolio.

 

HS Productivity dashboard widget.png

 

I'd like to pull each of these metrics for just two specific HubSpot users who are customer service reps for (1) the past 30 days and (2) the past 30-60 days. 

  1. Total # of Emails sent to Contact by person A or person B in the last 30 days
  2. Total # of Emails sent to Contact by person A or person B in the last 30 - 60 days
  3. Total # of Calls made by person A or person B in the last 30 days
  4. Total # of Calls made by person A or person B in the last 30 - 60 days
  5. Total # of Tasks done by person A or person B in the last 30 days
  6. Total # of Tasks done by person A or person B in the last 30 - 60 days
  7. Total # of Notes from person A or person B in the last 30 days
  8. Total # of Notes from person A or person B in the last 30 - 60 days
  9. Total # of Email replys received from a contact by person A or person B in the last 30 days
  10. Total # of Email replys received from a contact by person A or person B in the last 30 - 60 days

To clarify - I don't need the line-by-line record details, but just the Total # of each engagement as laid out above.

 

Can you please advise what the API queries would look like to pull this data?

 

Thanks in advance!

0 Upvotes
3 Replies 3
WendyGoh
HubSpot Employee
HubSpot Employee

API queries to replicate the data in the Productivity widget from the Sales dashboard

Hey @cfrye_1st_page,

 

I hope all is well with you 🙂

 

As of now, when using the Engagement APIs here - Get all engagements, it'll return all the portal's engagements and it's not possible to filter the engagements to specifically return only e.g. TYPE = EMAIL. 

 

There also isn't an endpoint to simply pull out the Productivity report. That said, as discussed in this thread - Pull Sales Performance widget data, one other way that we can get the engagements information is to use the Contact Lists API, where you can create list with the following filter criteria:

#1 Activity created by e.g. Person A or Person B

#2 Activity date is between e.g. 06/01/2019 and 06/30/2019 (note: there isn't a way to set it as last 30/60 days)

#3 Activity type is any of e.g. Email sent to contact 

***You can change this accordingly based on the engagements that you'd like to pull in

 

Once we have the lists set up, we can use this endpoint here: Get a group of contact lists > To get the "size" of the list which fits your end goal as it'll return the total engagements instead of a line-by-line record details.

 

Additionally, for this I'd also love to share with you this documentation on how to use HubSpot Activity filters.

 

Hope this helps to clarify!

 

cfrye_1st_page
Participant | Partner
Participant | Partner

API queries to replicate the data in the Productivity widget from the Sales dashboard

Hi @WendyGoh 

 

Thanks for your followup here. I think I'm following but now I'm stuck stitching the pieces together. 

 

Step 1: create new dynamic contact list via API - I think I'd be using the following POST URL but I'm not sure how to append the filter criteria

https://api.hubapi.com/contacts/v1/lists?

 

Then to create the list for emails sent by the 2 people 30-60 days ago, I'd use the following criteria

{

  "name": "CSR Emails 30-60 days ago",

  "dynamic": true,

  "portalId": xxxxx,

  "filters":

  [

   {

    "operator":"SET_ANY",

    "property":"ACTIVITY_CREATED_BY",????;????,

    "ACTIVITY_TYPE":"email",

      {"operator":"GTE",

      "property":ACTIVITY_DATE",

      "value":(insert unix code for 30 days ago)

    },

      {

        "operator":""LTE",

        "property":ACTIVITY_DATE",

        "value":(insert unix code for 60 days ago)

      }

  ]

}

 

Step 2: Pull the size of that contact list via API using a call like this

https://api.hubapi.com/contacts/v1/lists/batch?listId=xxxx

 

Questions:

1. Is that filtering criteria set properly?

2. How do I find the user ID's to plug into the ACTIVITY_CREATED_BY fitler?

3. How do I set these filters into the POST API call?

4. Will the list id change or stay constant every time the list is created in the first step? 

 

Thanks!

0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

API queries to replicate the data in the Productivity widget from the Sales dashboard

Hi @cfrye_1st_page,

 

Thank you for your response!

 

Pardon for the misalignment of goals in my first response. Now, I understand that you're looking to pull the number of engagements of certain types belonging to certain users. The list workaround that I mentioned previously can only be created for the contact object, so this wouldn't be able to help you get the number of activities. 

The best solution here will involve using the Get Recent Engagements API  and counting all of the engagements of each type that belong to each user.

0 Upvotes