Bokun Google Contacts Sync
A Custom-based solution to sync Bokun client contacts with Google Contacts using webhooks. It fetches data via webhooks and updates selected contacts in Google Contacts automatically.
Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/codesproutx/bokun-google-contact-sync/archive/refs/heads/master.zip
Data flow: Bokun → Webhook → WP Plugin → Google People API → Google Contacts
A WordPress plugin that automatically synchronizes customer booking data from Bokun to Google Contacts using webhooks and the Google People API.
Features
- 🔄 Real-time Webhook Integration: Processes Bokun booking webhooks
- 📱 Google Contacts API: Creates contacts using Google People API v1
- 👥 Multi-Account Support: Supports up to 5 Google accounts
- 🔐 OAuth2 Authentication: Secure Google authentication
- 📊 Data Management: Admin interface with data tables
- 🔍 Duplicate Prevention: Prevents duplicate contacts
- 📞 Phone Processing: Phone number formatting rules
- 📝 Logging: Detailed error tracking
Requirements
- WordPress 5.0 or higher
- PHP 7.4 or higher
- Google Cloud Platform project with People API enabled
- Bokun account with webhook capabilities
- Composer (for dependency management)
Installation
- Install Plugin: Upload to
/wp-content/plugins/and activate - Install Dependencies: Run
composer install - Google Cloud Setup:
- Create project at Google Cloud Console
- Enable People API
- Create OAuth 2.0 credentials (Web application)
- Add redirect URI:
https://yoursite.com/wp-admin/admin.php?page=bokun-google-contacts-sync - Download credentials.json: After creating OAuth credentials, click "Download JSON" and save as
credentials.jsonin the plugin root directory
- Configure Plugin:
- Go to WordPress Admin → Bokun Google Contacts
- Enter Google API credentials (Client ID, Client Secret) or upload
credentials.json - Set up Bokun webhook URL:
https://yoursite.com/bokun-google-contacts-sync-webhook
Note: The credentials.json file contains sensitive OAuth credentials and should never be committed to version control. It's automatically excluded from Git via .gitignore.
Setup
- Google Accounts: Click "Initiate OAuth" for each account, complete authentication
- Bokun Integration: Enter vendor IDs, configure webhook URL in Bokun dashboard
- Phone Rules (Optional): Set up phone number formatting and replacement rules or configure special character removal
Management
- View Data: Go to "Sync Logs" to see synchronized bookings
- Operations: Delete individual entries or bulk delete all data
- Monitoring: Filter by account, date, or status
The plugin automatically processes webhooks for new bookings, status changes, and customer updates.
Configuration
- Google API: Client ID, Client Secret, Redirect URI (auto-configured)
- Accounts: Custom names, vendor IDs, access tokens (auto-managed)
- Phone Processing: Replacement rules, special character removal, validation
File Structure
bokun-google-contacts/
├── bokun-google-contacts.php # Main plugin file
├── bokun-booking-data.php # Data display template
├── index.php # Security file
├── composer.json # Dependencies
├── credentials.json # Google Cloud OAuth credentials
├── assets/
│ ├── css/
│ │ └── admin.css # Admin styling
│ └── architecture.svg # Plugin interface diagram
└── README.md # This file
API Endpoints
- Webhook:
/bokun-google-contacts-sync-webhook(POST) - Receives Bokun data - AJAX:
fetch_bokun_bookings,delete_bokun_booking_orders,remove_all_synced_bokun_booking_orders
Security
- Data encryption, nonce verification, admin-only access, input sanitization
Troubleshooting
OAuth Issues: Verify Google API credentials, redirect URI, enable People API Webhook Issues: Check webhook URL in Bokun, server logs, endpoint accessibility Contact Creation: Verify Google permissions, access token validity, error logs
Enable debug mode in wp-config.php:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
Logging
- Webhook data:
webhook_raw.log - Errors:
webhook_errors.log - Contact creation attempts
- Authentication events
License
Proprietary software. All rights reserved.
Author
lakshmi - Plugin Developer
Note: Requires Google API credentials and Bokun webhook configuration.