SDK Only

Selfbook Implementation with SDK only

SDK

Step 1: Insert this js code above the </ body > tag in the index page

<script async type="text/javascript"
        src="https://sdk.selfbook.com/api/sdk.min.js?hotelId={Insert-your-hotel-id}&apiKey={Insert-your-API-key}"
        id="selfbook_jssdk"
        >
</script>

🚧

Initilization

The SDK script above should be initialized when the main hotel page loads. Initializing it conditionally (Example, with a button or other user interactions) will not integrate properly with the rest of Selfbook features like Direct Link customized URLs.

Step 2: In the button where you need to open the widget form, call this function along with the parameters if available

🚧

NOTE

All parameters are optional; if a parameter is not provided please just set it as an empty field.

The parameters types for bookNow() function are the following:

bookNow({
            startDate: string,
            endDate: string,
            guests: Array,
            propertyId: string,
            currencyCode: string,
            roomId: string,
            ratePlanCode: string,
            promoCode: string,
            groupCode: string,
            locale: string,
            hotelId: number,
        });
  • Locale is language ISO 2 code
  • If a hotel belongs to a group and Selfbook is opened from the group page, send the hotel id in the BookNow function.

Example of bookNow() function below:

bookNow({
    "startDate": "2021-09-20",
    "endDate": "2021-09-24",
    "guests": [
        {
            "type": "adult",
            "count": 2
        },
        {
            "type": "child",
            "count": 0
        },
        {
            "type": "infants",
            "count": 0
        }
    ],
    "propertyId": "property-id",
    "roomId": "room-id",
    "ratePlanCode": "rate-plan-code",
    "promoCode": "promo-code",
    "groupCode": "group-code",
    "locale": "locale-iso2-code",
    "hotelId": 67998
});

What’s Next