How to trigger surveymonkey collector through a hubspot form submission


#1

Is there a way to trigger a surveymonkey survey to be administered when a contact submits a hubspot form? It seems feasible because surveymonkey has an API, but I am not sure how and where to call their API when a Hubspot form is submitted.


#2

Hi @yidan621,

It's not possible out of the box, but in theory you could write a script that did this for you. If you can trigger a survey via the SurveyMonkey API, you might consider creating a custom form & submitting to the Forms API. This would allow your server to also trigger the SurveyMonkey survey before passing the data along to HubSpot. Alternatively, if you have access to the workflows tool, you could use a workflow webhook action to trigger a webhook to your server after a contact submits your form.


#3

Thanks Derek! I will try that :slight_smile:


#4

Here is how I did it (For anyone interested in implementing this yourself)

  1. Create a Google App Script file https://script.google.com
  2. create a doPost(e) function -
    function doPost(e){
    var contactData = JSON.parse(e.postData.contents);
    //parse and retrieve info about the contact record
    var email = contactData.properties.email.value;

//call Survey Monkey API to create the collector
var data = {
"type": "weblink",
"name": email
}
var options = {
'method' : 'post',
'headers':{'Authorization':'bearer your_access_token'},
'contentType': 'application/json',
// Convert the JavaScript object to a JSON string.
'payload' : JSON.stringify(data),

};

var result = UrlFetchApp.fetch('https://api.surveymonkey.com/v3/surveys/{surveyID}/collectors', options);

}

(Get the access token by creating a private survey monkey app, retrieve the surveyID using another API call first)

  1. Publish the script as a web app, and copy the URL.
  2. Create a workflow in Hubspot: when the form is submitted, trigger a webhook. Enter the copied URL as the endpoint

Tips:
1.Always publish the Google App Script as a new version when you make changes.
2. Refer to SurveyMonkey's API for optional parameters. Pay attention to the data type, especially for date fields.
3. SurveyMonkey has a API call limit (120 per minute, 500 per day)