WordPress Elementor Contact Forms Leads Integration

If you using Elementor Contact Forms on your WordPress website for your Travel Business and want to bring the contact form submission leads automatically inside your Sembark Travel CRM software, this guidelines is for you.

Requirements

Before you proceed, please check if your meet the following requirements.

  1. Sembark Travel CRM Account.
  2. WordPress website with Elementor Forms
  3. Access Token generated from Sembark Travel CRM.

Once you have the above requirements completed, you can proceed.

Send Form Submissions

Now, lets send the data from your Contact Form submissions to Sembark API.

1. Attach Elementor Hook

Please put the following code snippet inside a functions.php file located inside your themes folder. Please ensure the your already have Elementor Contact Forms Requirements on your website, otherwise this will not work.

<?php
function send_elementor_form_data_to_api($form_data) {

  /**
  * TODO 1: Get this token from the Sembark CRM Admin account
  */
  $access_token = "<<<ACCESS_TOKEN_HERE>>>";

  /**
  * TODO 2: Update this mapping to set the payload for Sembark API
  */
  // On the right side, you have your form data
  // On the left side, you have Sembark's Acceptable Keys
  // Reference: https://sembark.com/travel-software/apis/trip-plan-requests/#request-body
  $payload = [
    'name' => $form_data['your_name'], // your name is the field in your contact form
    'phone_number' => $form_data['phoneNumber'], // phoneNumber is the fields in your contact form
    // add more fields
  ];

  // Send the request
  $response = wp_remote_post('https://api.sembark.com/integrations/v1/trip-plan-requests', [
    'body' =>  wp_json_encode($payload),
    'data_format' => 'body',
    'headers' => [
       'Content-Type' => 'application/json',
       'Accept' => 'application/json',
       'Authorization' => 'Bearer ' . $access_token 
    ]
    ]);
  if ( is_wp_error( $response ) ) {
    $error_message = $response->get_error_message();
    // TODO: Handle the error
  }
}

add_action('elementor_pro/forms/new_submission', 'send_elementor_form_data_to_api');

?>

As you can see in the snippet, we have 2 more todos to complete.

2. Access Token

Now we will update the $access_token with a value which you can get from Sembark Dashboard. Check the Authorization Documentation on how to generate an access token.

Once you have generated a token, replace the <<<ACCESS_TOKEN_HERE>>> with it in the above snippet.

  /**
  * TODO 1: Get this token from the Sembark CRM Admin account
  */
-  $access_token = "<<<ACCESS_TOKEN_HERE>>>";
+  $access_token = "your_generated_access_token_here";

3. Field Mapping

The final step is to map your Elementor Contact Form Fields to the Sembark API's request fields. You already have some fields (e.g. First Name, Last Name, Email etc.) from your Elementor Forms. We will map these fields to the fields expected by Sembark APIs.

What is Mapping

Mapping is associating or connecting each field of (a set) with a field of another set. In this case, we will associate field(s) from your Elementor Contact Form (a set) to field(s) of Sembark APIs (another set).

Sembark APIs accept data in particular key-value format. Incase of Leads API, following fields are available. For an up-to-date information of fields, please visit the respective APIs documentation page.

{
  'name': string // Guest Name, required (max: 191)
  'phone_number': string // Guest Phone Number, required (max: 191)
}

Now assuming you have following fields in your Contact Form and you want to send them to Sembark Leads API.

  • Name
  • Email
  • Contact Number
  • Destination
  • Comments
  • Package Category

Where to find these Name

You can find them inside your Elementor Form's Input's name attribute. Sometimes, these are same as the Label for your fields in Forms.

Now we will map these Contact Form's fields to appropriate available fields in Sembark Leads API.

Contact Form FieldSembark Field
Namename
Emailemail
Contact Numberphone_number
Destinationdestination
Commentscomments
Package Category

We will put these Sembark Fields in the mapping inputs of your contact-form fields respectively. As you can see, Package Category is left blank as it doesn't have a corresponding field in the Sembark API.

Now let's update our code snippet to include this mapping.

  /**
  * TODO 2: Update this mapping to set the payload for Sembark API
  */
  // On the right side, you have your form data
  // On the left side, you have Sembark's Acceptable Keys
  // Reference: https://sembark.com/travel-software/apis/trip-plan-requests/#request-body
  $payload = [
+    'name' => $form_data['Name'],
+    'phone_number' => $form_data['Contact Number'],
+    'destination' => $form_data['Destination'],
+    'comments' => $form_data['Comments'],
  ];

+ // Add the other form fields as it is
+ $payload = array_merge(
+   $payload, // mapped fields
+   array_diff_keys(
+    $form_data,
+    array_flip(['Name', 'Contact Number', 'Destination', 'Comments'] // remove these keys as they are mapped
+   )
+ );

Once you have updated the snippet with above steps, it is time to test the flow.

Test Your Submission

To test the submission, simply fill out the Elementor Contact/Lead form on your Wordpress Website and test the data inside your Sembark Dashboard under Trips > Trip Plan Requests tab from top header navigation.

If you need more help, please recheck the above steps or contact our support channel for your organization.

Share

Contact Us

Please feel free to contact us for your queries or demo requests. Provide your contact details and our team will connect you shortly afterwards.

Office Address

1, Plot No 177A, Shyam Enclave Sirsi, Jhotwara
Jaipur, Rajasthan, India - 302034

Specify the type of Travel Company