Skip to main content
In some instances you may want to capture data using a Candu Form and then pass that data into your product. For example when onboarding new users you might create forms to collect essential information to configure their account so you can tailor your products content or recommendations. Examples include:
  • The name of a project, organization or store
  • Preferred language
  • Name of their profile or team
There are two ways to get the data: in the browser with onFormSubmit, or on your server with webhooks.

Option 1: In the browser with onFormSubmit

Pass an onFormSubmit function when you initialize Candu. It runs on every Candu form submission in that page session and receives the form’s details and the submitted values (field label to value), so you can check which form it was and use the values in your own code.
Use this when the data only needs to reach the page the user is on. Use webhooks (below) when your backend needs it reliably.

Option 2: On your server with webhooks

  1. Create your Form in Candu
  2. Configuring Webhooks for Form Responses
    • Guide to this is here.
    • Submissions made in the editor preview don’t fire webhooks. Test by publishing to a segment that only contains you and submitting in your live app.
  3. Handling Webhook Requests:
    • In your product, you need to create a webhook endpoint to receive the data from Candu.ai.
    • Set up an endpoint in your backend application that will listen for incoming requests from Candu.ai. This endpoint should be able to accept `POST requests.
    • Depending on the programming language and framework you’re using, you can set up a route or controller to handle the incoming webhook requests.
  4. Parsing and Processing the Webhook Data:
    • When a webhook request is received at your endpoint, you’ll need to extract and process the relevant data from the request payload.
    • Parse the JSON or form-encoded data sent by Candu.ai to extract the form field values.
    • Validate and sanitize the data as per your product’s requirements.
    • You can then perform any additional processing or transformation on the data if needed.
  5. Populating the Data in Your Product:
    • Once you have extracted and processed the data, you can use it to populate your product’s internal database or perform any other desired actions.
    • This could involve storing the form data in a database, triggering specific actions based on the form submissions, or displaying the captured data in your product’s user interface.
Remember, the specifics of implementing webhooks and processing the data will depend on the programming language, framework, and infrastructure you are using for your product. However, the general steps outlined above should give you a good starting point for capturing form data from Candu and populating it in your own product.