If you using Formidable 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 guide is for you.
Requirements
Before you proceed, please check if your meet the following requirements.
- Sembark Travel CRM Account.
- WordPress website with Formidable Forms
- 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 Formidable Forms Hook
Please put the following code snippet inside a functions.php
file located inside your themes folder. Please ensure the your already have Formidable Forms Requirements on your website, otherwise this will not work.
<?php
if (!function_exists('send_formidable_forms_data_to_api')) {
function send_formidable_forms_data_to_api($entryId, $form_data, $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
$item_meta = $_POST['item_meta'];
$payload = [
'name' => $item_meta[30], // update 30 with propper field ID
'phone_number' => $item_meta[31], // update 31 with propper field ID for phone number
// 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('frm_after_create_entry', 'send_formidable_forms_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 Formidable Forms Fields to the Sembark API's request fields. You already have some fields (e.g. First Name, Last Name, Email etc.) from your Formidable 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 Formidable Forms (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
- Contact Number
- Destination
- Comments
- Package Category
Where to find these Name
You can find them inside your Formidable Forms's Input's name
attribute.
Now we will map these Contact Form's fields to appropriate available fields in Sembark Leads API.
Contact Form Field | Field ID | Sembark Field |
---|---|---|
Name | 31 | name |
32 | ||
Contact Number | 33 | phone_number |
Destination | 34 | destination |
Comments | 35 | comments |
Package Category | 36 |
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' => $item_meta[31],
+ 'email' => $item_meta[32],
+ 'phone_number' => $item_meta[33],
+ 'destination' => $item_meta[34],
+ 'comments' => $item_meta[35],
];
+ // Add the other form fields as it is or with a custom field
+ $payload = array_merge(
+ $payload, // mapped fields
+ [
+ 'Package Category' => $item_meta[36]
+ // 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 Formidable Forms 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.