• Resolved nikhilmozika

    (@nikhilmozika)


    Use?Case?Overview: We are collecting leads through forms on various landing pages, and these leads are integrated into our CRM via a webhook. The CRM has limited field mapping capabilities, allowing only basic fields such as name and email to be mapped directly.

    For other crucial customer details—like the child’s name, date of birth (DOB), and the services they are interested in—we use a generic “additional info” key field to capture these details in bulk.

    Current?Issue: When configuring the webhook for field mapping, the webhook integration presents a dropdown for mapping only one value at a time. However, we need the ability to map multiple values (such as DOB, child’s name, and service required) to the “additional info” field using a multi-select option.

    While I can combine values using custom HTML and dynamic input values, these concatenated values are not being properly stored or displayed after submission. I need either a solution to modify the webhook’s behavior to support multi-select mapping or a custom code solution that ensures the concatenated values are properly passed and stored in the CRM.

    For this the solution suggest is this:

     // Hook into the FluentForm webhook to combine fields before sending data
    add_filter('fluentform/webhook_request_data', function ($selectedData, $settings, $data, $form, $entry) {

    // Retrieve individual field values from form submission data.
    $dropdown1 = isset($data['service_required_1725528048418']) ? $data['service_required_1725528048418'] : '';
    $dropdown2 = isset($data['preschool_branch']) ? $data['preschool_branch'] : '';
    $dropdown3 = isset($data['activity_type']) ? $data['activity_type'] : '';
    $dob = isset($data['child_s_dob_1725528397702']) ? $data['child_s_dob_1725528397702'] : '';
    $name = isset($data['child_name']) ? $data['child_name'] : '';

    // Combine the dropdowns, date of birth, and name into a single string.
    $combinedField = $name . ' - ' . $dropdown1 . ', ' . $dropdown2 . ', ' . $dropdown3 . ' - DOB: ' . $dob;

    // Add the combined field to the webhook data.
    $selectedData['combined_info'] = $combinedField;

    // Return the modified webhook data.
    return $selectedData;

    }, 10, 5);

    I have added this to the functions.php file but now how should I map the “combined_info” with the “additional_info” key or feild name.

    https://drive.google.com/file/d/17qkhiDgCH69zkiN7Gb9qf80ktYe6fH-I/view?usp=sharing

    Help me out here.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Amimul Ihsan Mahdi

    (@amimulihsanmahdi)

    Hello @nikhilmozika,

    Please note that assisting with custom codes falls beyond our support scope. From the description you have shared, I can see that you are trying to send nested data to a webhook. By default, Fluent Forms does not offer the functionality to add nested JSON data. For instance, if the webhook requires data in below format then it is not possible to pass the data via Fluent Forms webhook by default.

    {
    "id": 123,
    "email" : "[email protected]"
    "combined_info": {
    "name": "Test",
    "date_of_birth": "12/07/1980"
    }
    }

    If you would like to modify your webhook data using the filter hook to add combined info then you may proceed by mapping email and id in the webhook feed. After that you can add the below code to add combined_info data.

    add_filter('fluentform/webhook_request_data', function ($selectedData, $settings, $data, $form, $entry) {

    $selectedData['combined_info'] = [
    'name'=> $data['name'],
    'date_of_birth'=> $data['date_of_birth']
    ];

    return $selectedData;
    }, 10, 5);

    In the above example code we have used $data[‘name’] to map the data. However, if the name attribute of the name field is different, you can change ‘name’ with the name attribute of the field. The same rules goes for the date_of_birth field.

    Thank you

    Thread Starter nikhilmozika

    (@nikhilmozika)

    I understand the code and as you can see I have created one myself and the same is working fine. The combined feild needs to be mapped in the webhook how to do that. In you example I need to pass the “combined_info” to the webhook.

    Do I need to create more code. I just need guidance in this regard.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.