WordPress Quforms Leads Integration

If you using Quforms 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 guide is for you.

Requirements

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

  1. Sembark Travel CRM Account.
  2. WordPress website with Quforms
  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 Quforms Hook

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

if (!function_exists('send_quform_data_to_sembark_leads_api')) {
	function send_quform_data_to_sembark_leads_api($result, $form) {
    /**
    * 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->getValue('quform_1_3'),
      'email' =>  $form->getValue('quform_1_4'),
      'phone_number' =>  $form->getValue('quform_1_5'),
      'no_of_adults' =>  $form->getValue('quform_1_9'),
      'start_date' =>  $form->getValue('quform_1_7'),
      'destination' => 'Uttarakhand',
      // 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
    }
    return $result;
  }

  // https://support.themecatcher.net/quform-wordpress-v2/guides/integration/sending-form-data-to-another-script
  add_action('quform_post_process_1', 'send_quform_data_to_sembark_leads_api', 10, 2);
}
?>

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 Quforms Fields to the Sembark API's request fields. You already have some fields (e.g. First Name, Last Name, Email etc.) from your Quforms. 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 Quforms (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 Quforms's Input's name attribute.

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

Contact Form FieldForm Field NameSembark Field
Namequform_1_1name
Emailquform_1_3email
Contact Numberquform_1_4phone_number
Destinationquform_1_10destination
Commentsquoform_1_2comments
Package Categoryquoform_1_8

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->getValue("quform_1_1"),
+    'email' => $form->getValue("quform_1_3"),
+    'phone_number' => $form->getValue("quform_1_4"),
+    'destination' => $form->getValue("quform_1_10"),
+    'comments' => $form->getValue("quoform_1_2"),
  ];

+ // Add the other form fields as it is or with a custom field
+ $payload = array_merge(
+   $payload, // mapped fields
+   [
+       'Package Category' => $form->getValue("quoform_1_8"),
+       // add other similar fields
+   ]
+ );

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 Quforms 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