Auto-Assign Packages
This guide demonstrates how to integrate Hubby eSIM with your Outbound Travel Business (OTA) platform for maximum conversion and minimal customer friction. We'll cover how to automatically send bookings to Hubby and leverage our package strategy system for optimal package assignment.
Overview
In this integration pattern:
- Your OTA sends all travel bookings to Hubby
- Hubby automatically assigns appropriate eSIM packages based on your predefined strategy
- Travelers receive their eSIM details automatically via email
- You maintain full visibility over the booking lifecycle
Prerequisites
- A Hubby Partner account with API access
- Your API credentials (public key and secret)
- A configured package strategy (contact support to set this up)
API Endpoints
Hubby provides two API endpoints for different environments:
- Production:
https://api.hubbyesim.com/api- Use this for live applications - Staging:
https://api-staging.hubby.dev/api- Use this for testing and development
Always test thoroughly in staging before using production.
Package Strategies
Hubby supports several package assignment strategies that can be configured for your account:
- Budget Strategy: Assigns packages to maintain similar costs across destinations
- Fixed Size Strategy: Provides consistent data amounts regardless of destination
- Hybrid Strategy: Combines approaches based on regions or other criteria
Contact our support team to configure the optimal strategy for your business model.
Implementation Steps
1. Authentication Setup
First, implement the HMAC authentication system:
const crypto = require('crypto');
function generateHeaders(method, path, timestamp) {
const payload = timestamp + method + path;
const signature = crypto
.createHmac('sha256', process.env.HUBBY_API_SECRET)
.update(payload)
.digest('hex');
return {
'x-api-key': process.env.HUBBY_API_KEY,
'x-timestamp': timestamp,
'x-signature': signature,
'Content-Type': 'application/json'
};
}2. Booking Creation
When a customer makes a booking, send it to Hubby with just the destination:
// Use staging for development, production for live
const API_BASE_URL = process.env.NODE_ENV === 'production'
? 'https://api.hubbyesim.com'
: 'https://api-staging.hubby.dev';
async function createEsimBooking(bookingData) {
const timestamp = Date.now().toString();
const path = '/api/bookings';
const response = await fetch(`${API_BASE_URL}/api/bookings`, {
method: 'POST',
headers: generateHeaders('POST', path, timestamp),
body: JSON.stringify({
booking_id: bookingData.bookingId,
departure_date: bookingData.departureDate,
email: bookingData.customerEmail,
first_name: bookingData.firstName,
last_name: bookingData.lastName,
package_specifications: [{
destination: bookingData.countryCode // Just specify the country code
}],
communication_options: {
should_send_message: true,
channels: ["EMAIL"]
}
})
});
return await response.json();
}3. Handling the Response
async function handleBookingResponse(bookingResponse) {
if (bookingResponse.success) {
// Store the Hubby booking ID for future reference
await updateBookingRecord({
hubbyBookingId: bookingResponse.data.id,
promocodes: bookingResponse.data.promo_codes
});
} else {
// Handle error cases
console.error('Booking creation failed:', bookingResponse.error);
}
}Best Practices
- Early Integration: Send the booking to Hubby as soon as the travel booking is confirmed
- Error Handling: Implement robust error handling and retry mechanisms
- Booking ID Storage: Store Hubby's booking ID alongside your booking records
- Communication: Let customers know they'll receive eSIM details via email
Example Integration Flow
Here's a complete example of how to integrate the booking flow:
const express = require('express');
const router = express.Router();
router.post('/bookings', async (req, res) => {
try {
// 1. Create your travel booking
const travelBooking = await createTravelBooking(req.body);
// 2. Create Hubby eSIM booking
const esimBooking = await createEsimBooking({
bookingId: travelBooking.id,
departureDate: travelBooking.departureDate,
customerEmail: travelBooking.customerEmail,
firstName: travelBooking.firstName,
lastName: travelBooking.lastName,
countryCode: travelBooking.destination
});
// 3. Handle the response
await handleBookingResponse(esimBooking);
// 4. Return success to customer
res.json({
success: true,
message: 'Booking confirmed! Check your email for eSIM details.'
});
} catch (error) {
res.status(500).json({
success: false,
error: 'Booking failed. Please try again.'
});
}
});Monitoring and Support
Monitor your integration using:
- Booking success rates in your Hubby dashboard
- Email delivery status for eSIM details
- Customer activation rates
Contact support@hubbyesim.com for:
- Package strategy configuration
- Integration support
- Performance optimization