Neo4j Create Booking
AI-generatedOverview
This node creates a new booking record in a Neo4j graph database. It first verifies the availability of the requested booking based on the service's booking mode, which can involve time-only, resource-only, staff-only, or combined staff and resource checks. After confirming availability, it inserts a booking node linked to the customer, business, service, and optionally staff and resource usage nodes.
Common scenarios:
- Scheduling appointments for customers at a business with specific services.
- Managing bookings that require allocation of staff members and/or resources.
- Ensuring no double-booking by checking availability before creating records.
Practical example:
A salon uses this node to book hair styling services. When a customer requests a booking, the node checks if the stylist (staff) and necessary equipment (resource) are available at the requested time. If available, it creates a confirmed booking linked to the customer, stylist, and equipment.
Properties
| Name | Meaning |
|---|---|
| Customer ID | The unique identifier (UUID) of the customer making the booking. |
| Business ID | The unique identifier (UUID) of the business where the booking is made. |
| Service ID | The unique identifier (UUID) of the service being booked. |
| Booking Time | The start date and time of the booking in ISO 8601 format with timezone information. |
| Staff ID (Optional) | The unique identifier (UUID) of the staff member assigned. Required if the service booking mode involves staff. |
| Resource Type ID (Optional) | The unique identifier (UUID) of the resource type required. Required if the service booking mode involves resources. |
| Resource Quantity (Optional) | The quantity of the resource type required. Defaults to 1. Used only if Resource Type ID is provided. |
| Notes (Optional) | Additional notes or comments related to the booking. |
Output
The node outputs an array of JSON objects representing the created booking(s). Each output item contains a booking object with properties such as:
booking_id: Unique identifier of the booking (UUID).customer_id,business_id,service_id: IDs linking the booking to respective entities.booking_time: The booking start time, converted to the detected or business timezone.status: Booking status, set to"Confirmed".notes: Any additional notes provided.- Optionally includes
staffId,resourceTypeId, andresourceQuantitydepending on the booking mode. created_at: Timestamp when the booking was created.
If the node encounters errors during processing, it outputs an error message in the error field instead of booking data.
Dependencies
- Neo4j Database: Requires access to a Neo4j instance with appropriate credentials (host, port, username, password, optional database name).
- Neo4j Driver: Uses the official Neo4j JavaScript driver to connect and run Cypher queries.
- Helper Modules: Utilizes internal helper functions for:
- Running Cypher queries.
- Parsing and normalizing date/time values.
- Checking availability based on booking modes.
- Generating resource usage creation queries.
- Credentials Configuration: The node requires configuration of an API key credential containing Neo4j connection details.
Troubleshooting
Common Issues
- Missing or incomplete Neo4j credentials: The node will throw an error if host, port, username, or password are missing.
- Invalid booking time format: The booking time must be in ISO 8601 format with timezone; otherwise, an error is raised.
- Service not found or missing booking mode: If the specified service ID does not exist or lacks a booking mode, the node fails.
- Required fields missing for booking mode: For example, Staff ID is mandatory for "StaffOnly" or "StaffAndResource" modes; Resource Type ID is mandatory for "ResourceOnly" or "StaffAndResource".
- Availability check failures: If the requested time, staff, or resources are unavailable, the node throws an error indicating unavailability.
- Neo4j connectivity issues: Errors connecting to the database or opening sessions will cause the node to fail.
Error Messages and Resolutions
- "Neo4j credentials are not fully configured or missing required fields": Verify all required credential fields are correctly set.
- "Invalid booking time format": Ensure the booking time input follows ISO 8601 with timezone, e.g.,
2024-06-01T14:00:00+02:00. - "Service not found with ID": Confirm the service ID exists in the Neo4j database.
- "Booking mode not set for service ID": Check that the service node has a valid booking mode property.
- "Resource Type ID is required for ResourceOnly service booking mode": Provide a resource type ID when booking such services.
- "Staff ID is required for StaffOnly service booking mode": Provide a staff ID when booking such services.
- "Unsupported booking mode": The node supports only predefined booking modes; verify the service's booking mode value.
- "Failed to connect to Neo4j or open session": Check network connectivity, credentials, and Neo4j server status.