CommCare - HubSpot Integration

Hi there CommCare Community,

I was just wondering if anyone has integrated CommCare with HubSpot before and if so if they have any tips on how best to approach this.

Our project is looking into using HubSpot to conduct automated data reporting and analytics with our data collected by CommCare in the field.

Any advice would be great.

Thanks,

Dylan

Hey Dylan,

Depending on your use case, the first thing I’d explore is trying to accomplish the integration via Zapier.

https://confluence.dimagi.com/display/commcarepublic/Zapier+Integration

Cory

Hi Corey,

Thanks very much for the suggestion. We will look into it as a potential option.

Many thanks!

Dylan

Hi @czue, Is there any open source solution/technology for those integrations? I want to avoid zapier. Does commcare API provide event-driven solution for this? for example if commcare create a contact, it’d trigger hubspot API to update their data. Is this possible? Should I need to setup a server?
Thanks

Hey,

Commcare does have a data forwarding API that is event-driven, but only for forms and cases. If your contacts are cases then you might be able to set something up, but I’m guessing you’d still need an intermediary process to translate between CommCare’s format and what hubspot expects. If your contacts are users then you’d currently have to do a polling method on the User API.

What’s the use case you’re using this for?

Thanks for the hints @czue, really appreciate it. My cases are to communicate and synchronize data from commcare and hubspot and vice versa. From an example earlier, a contact created on commcare would be synchronized with data on hubspot. also lead created on hubspot would be added in commcare contact. also many others data would be back and forth between commcare and hubspot. They are still vague on me how to make that happen. I’d really appreciate if there is a tutorial about this (no need to be specifically with hubspot). I’m still learning about commcare Data Forwarding and Enabling Data Integration (Form and Case Forwarding).

I got a link about this integration that can be achieved by OpenFn (https://www.openfn.org/) and for commcare API (https://github.com/OpenFn/language-commcare). But I have no idea it’d work as expected. Do you have any insight about OpenFn? I’d be really appreciate it.
Thanks.

Hi @czue, Does Commcare API support webhook and provide notification to track any changes in near real-time instead of polling the server for changes?
Thanks

Hey Teddy,

I don’t have firsthand experience with OpenFn, but I have heard great things and definitely think it could be worth exploring.

The CommCare HQ data forwarding infrastructure is the closest thing that we have to webhooks. They will send a push payload to a configured endpoint when forms are received or cases are changed.

Sorry this is a better link than the one I shared last time: https://confluence.dimagi.com/pages/viewpage.action?pageId=12224128

Hi Cory,

Sorry for very late response, it’s been busy lately. Thanks for the pointer. Really appreciate it.
I’ve just setup the data forwarding on a commcare app. Also I already have a server and url domain for this data forwarding. the test link is good. But I’m struggling with the data capture (payload) from the data forwarding just for a start. I have a php file for this.

$content = $_POST; 
$file = "post.txt"; 
$commcare_data = '';

foreach($content as $key=>$value) {
    $commcare_data.= $key . "=" . $value . "\t";
}
$Saved_File = fopen($_SERVER['DOCUMENT_ROOT'].'/commcare/'.$file, 'a'); 
fwrite($Saved_File, '\n'.$commcare_data); 
fclose($Saved_File); 
?>

So basically I want to capture the payload then write it in a file. But I always get empty data. The payload format use JSON. How to get the payload on my php file? Can you enlighten me? Sorry for very basic question. Thanks.

EDITED:
Sorry, I modified the php script a bit. Now I can get the expected payload.

<?php 
$json = file_get_contents('php://input');
$content_array = json_decode($json, true);
//$commcare_data = parse_str($json, true);
$file = "post.txt"; 

$Saved_File = fopen($_SERVER['DOCUMENT_ROOT'].'/commcare/'.$file, 'a'); 
fwrite($Saved_File, PHP_EOL.json_encode($content_array)); 
fclose($Saved_File); 
?>

Hey Teddy,

Apologies, but I’m afraid I won’t be able to help with that level of debugging. If you can convince yourself that CommCare is doing something incorrectly don’t hesitate to report a bug.

best,

Cory

No problem @czue. Thanks for the helps. I really appreciate its.

@advcha @dpearse we’ve configured a few CommCare-CRM integrations using the OpenFn integration platform. How this might work:

  1. Setup CommCare data forwarding to send data to OpenFn: https://openfn.github.io/docs/source-apps.html#commcare-hq
  2. Configure a “job” in OpenFn to transform & map your data to a destination application (Hubspot). OpenFn can be configured to execute any Hubspot actions permitted via its REST API (see its API docs here)
  3. Turn “on” your OpenFn job to auto-process so that data flows in near real-time from CommCare to Hubspot

See here for an OpenFn platform overview & demo of a CommCare-to-Salesforce integration, but let me know if interested in learning more! We offer a free OpenFn plan for those interested in prototyping & trying out the platform.