1

I am trying to create Webhook from TYPEFORM app, which POSTS the values in JSON.

And I want the values (FirstName,Email,Mobile) to get stored in a Data Extension in SFMC.

When some one fills the form, the webhook POST the data in JSON format as below. I verified this via pipedream.com website as below. enter image description here

I can create a Webhook easiy on TYPEFORM as below, enter image description here

But what is the URL I must use?

Or is there any other easy way to integrate TYPEFORM with SFMC?

Note: I am aware that we can easily integrate to Sales CLoud via this connector.
https://help.typeform.com/hc/en-us/articles/360042732171-Salesforce-integration

4
  • You could create the webhook endpoint yourself using something like a CloudPages Code Resource to capture data posted by TypeForm and do something with the data, like write it to a data extension or interact with the Journey Builder API.
    – Macca
    Jul 14, 2020 at 6:32
  • @Macca exactly, as you rightly pointed out my requirement is to WRITE to a Data Extension... so how should I proceed? ... as per above suggestion instead of regular LANDING PAGE, I must create CODE RESOURCE which code resource shall I create JS, JSON ?.... any link or refence would be helpful Jul 14, 2020 at 6:40
  • Maybe you want to cover up your endpoint in the picture - i just entered the adress and got "success" ;) Jul 14, 2020 at 7:30
  • @JohannesSchapdick Yes in front end you get a success message, once anyone complete the form...I had provided the form link just to have a illustration... However, I have now REMOVED the link to the FORM.... Jul 14, 2020 at 9:23

2 Answers 2

2

Below is the solution to this, to pass data from Typeform application to SFMC using WebHooks, you basically need to use SSJS to parse JSON. Let me know if this helps.

This code should be executed in a Cloud page in SFMC and the link of this page should be used in the webhook you mentioned above. enter image description here

****Code starts *****

<script runat="server" language="javascript">

Platform.Load("Core","1");

var jsonpost = Platform.Request.GetPostData()

var json = Platform.Function.ParseJSON(jsonpost);

var text = json.form_response.answers[0]['text'] //field in your answer array in json

var email = json.form_response.answers[1]['email'] //email field in answer array

var phone_number = json.form_response.answers[2]['phone_number'] // fetching phone number field im answer array

Variable.SetValue("@text",text);

Variable.SetValue("@email",email);

Variable.SetValue("@phone_number",phone_number);

</script>


%%=v(@text)=%% //just printing this you can see the output in the response of a type form webhook, however, don't try to execute this code in the browser as it will give an error, as it works on server

enter image description here

%%=v(@email)=%%
%%=v(@phone_number)=%%

%%[
set @result = InsertData('Desired DE name' , "FirstName",@text, "EmailAddress", @email, "PhoneNumber",@phone_number) // insert your data to required DE
]%%

****Code ends *****

2
  • 1
    Thanks this is exactly what I was looking for 💡 Jul 14, 2020 at 15:40
  • 1
    You can use only SSJS for Inserting DE instead of using AMPscript as below ...... var rows = Platform.Function.InsertData("TypeFormDE",["FirstName","EmailAddress","PhoneNumber"],[text,email,phone_number]); Jul 15, 2020 at 7:53
1

There is small issue with the above solution, if we leave any of the input field blank and submit the form, the submission won't enter the Data Extension, as the above solution checks for exactly 0 to 2nd field in answer array and if any of the field value is missing the above logic goes wrong and it will give an error.

To resolve this issue, we just need to loop the array upto its length making using of for loop as below snippet -

 if (answers.length >=1)
    { 
       for(i = 0; i < answers.length;i++)
       {
           if(json.form_response.answers[i].text)
            { 
               text = json.form_response.answers[i].text
            }
           
           else if(json.form_response.answers[i].email)
           {
               email = json.form_response.answers[i].email
           }
         
          else if(json.form_response.answers[i].phone_number)
          {
              phone_number = json.form_response.answers[i].phone_number
          }
     }
}
2
  • 1
    Thanks Nobhunil, for sharing this additional info! Jul 17, 2020 at 4:47
  • Hi Vishal, did you get this to work? What would you use as the key if using the cloud page as the webhook URL?
    – s3002068
    Sep 7, 2020 at 3:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .