Create Integration
Visit your Organization's settings page from the top right dropdown. Then visit Integrations tab to view all your integrations.
From here, click on New Integration
. Provide a name and description to your integration and hit submit. On the next screen, copy the access token
to a safe place.
Integrate
Using the access token from previous step, you can access the Trip Plan Requests API. If you are already collecting leads from your landing pages, then you just need to forward these calls to Sembark APIs.
DANGER
You should NEVER put the Sembark API Access Tokens in the source code of your public sites (e.g. landing pages, marketing site, product site etc). If someone gets your token, they can use it to abuse your API usage.
Following the Trip Plan Requests API docs, here are sample code references to put on your servers. Here is a sample code for NodeJs projects to forward the form submissions to Sembark APIs.
TIP
If you are using WordPress with Contact Form Plugins, you might want to checkout out guidelines on WordPress integrations.
var axios = require("axios");
// assuming you already have guest_name, phone_number variables
var config = {
method: "post",
url: `https://api.sembark.com/integrations/v1/trip-plan-requests?name=${guest_name}&phone_number=${phone_number}`,
headers: {
Accept: "application/json",
Authorization: "Bearer <TOKEN_HERE>",
},
};
axios(config)
.then(function (response) {
// show the response.data.message
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
// handle the errors for 401/422/405/500 etc
console.log(error);
});
New Sites
If you aren't already collecting leads from your landing pages or you are just starting with your landing, you should first start collecting leads on your server.
Client Side
This part covers the steps needs on your landing pages.
Create Form
To collect the leads, we will add a form
on our landing page(s).
<form action="<SERVER_ENDPOINT_FOR_QUERIES_COLLECTION>" method="POST">
<input
name="guest_name"
required
type="text"
placeholder="Your Name e.g. Rahul Mehta"
/>
<input
name="phone_number"
required
type="tel"
placeholder="Your Contact Number e.g. +919999999999"
/>
<hr />
<button type="submit">Submit your Query</button>
</form>
Server Side
Collection Endpoint
You will need a server to collect the leads. If your site is already hosted on a server that you own (e.g. wordpress site), you are good to go. If your site is statically distributed on a third-party hosting provider, the you will need to setup a server.
After you create a server, here are sample code for your reference to collect the leads.
const express = require("express");
const bodyParser = require("body-parser");
const axios = require("axios");
const app = express();
// Configuring body parser middleware
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
// this will create an `/queries` endpoint (post) on our server
app.post("/queries", (req, res) => {
const data = req.body;
// we will send this `data` to the Sembark APIs
const config = {
method: "post",
url: `https://api.sembark.com/integrations/v1/trip-plan-requests?name=${data.guest_name}&phone_number=${data.phone_number}`,
headers: {
Accept: "application/json",
Authorization: "Bearer <TOKEN_HERE>",
},
};
return axios(config).then((resp) => {
res.send(
"Query submitted. Our sales executive will be in touch with you shortly.",
);
});
});
app.listen(80, () => console.log(`Hello world app listening on port 80!`));