Neo4j Find Available Slots TimeOnly icon

Neo4j Find Available Slots TimeOnly

根據時間查找可用的預約時間段 (僅考慮時間衝突),businessId: 要查詢可用時段的商家 ID (UUID),serviceId: 要預約的服務 ID (UUID) (用於獲取時長),startDateTime: 查詢範圍的開始時間 (ISO 8601 格式, 需含時區),endDateTime: 查詢範圍的結束時間 (ISO 8601 格式, 需含時區),intervalMinutes: 生成潛在預約時段的時間間隔(分鐘)

Neo4j Find Available Slots TimeOnly

AI-generated

Overview

This node queries a Neo4j database to find available booking time slots for a specific business and service within a given date/time range. It focuses on "time-only" availability, meaning it checks potential appointment times based on service duration and existing bookings without considering full date-time conflicts beyond the specified range.

Typical use cases include scheduling systems where you want to offer customers available appointment times for a particular service at a business, ensuring no overlapping bookings occur. For example, a salon might use this node to show clients all free 15-minute intervals between 9 AM and 5 PM on a certain day for a haircut service lasting 30 minutes.

The node:

  • Connects to Neo4j using provided credentials.
  • Retrieves the service duration from the database.
  • Generates potential time slots in the specified interval.
  • Checks each slot's availability against existing bookings.
  • Returns all available slots adjusted to the appropriate timezone.

Properties

Name Meaning
Business ID The unique identifier (UUID) of the business whose available slots are being queried.
Service ID The unique identifier (UUID) of the service to be booked; used to determine service duration.
Start Date/Time The start of the query range in ISO 8601 format including timezone (e.g., 2023-01-01T09:00:00+08:00).
End Date/Time The end of the query range in ISO 8601 format including timezone.
Slot Interval (Minutes) The length of each potential booking slot interval in minutes (minimum 1). Default is 15.

Output

The node outputs JSON data with the following structure:

{
  "availableSlots": ["2023-01-01T09:00:00+08:00", "2023-01-01T09:15:00+08:00", ...],
  "timezone": "Asia/Taipei",
  "mode": "TimeOnly",
  "serviceId": "service-uuid",
  "serviceDuration": 30,
  "checkedSlots": 32
}
  • availableSlots: An array of ISO 8601 datetime strings representing the start times of available booking slots.
  • timezone: The timezone string used for the returned slots, either detected from input or fetched from the business settings, defaulting to UTC if unavailable.
  • mode: Always "TimeOnly" indicating the mode of operation.
  • serviceId: The service identifier used in the query.
  • serviceDuration: Duration of the service in minutes.
  • checkedSlots: Total number of potential slots checked for availability.

No binary data output is produced by this node.

Dependencies

  • Requires a Neo4j database connection with valid credentials (host, port, username, password, optional database name).
  • Uses Neo4j driver for querying service duration and checking availability.
  • Relies on Luxon library for date/time parsing and manipulation.
  • Utilizes helper functions for normalizing dates, detecting timezones, and checking availability logic.
  • Requires proper configuration of an API key credential for Neo4j access in n8n.

Troubleshooting

  • Invalid Credentials Error: If Neo4j credentials are incomplete or incorrect, the node will throw an error about incomplete authentication configuration. Verify all required fields (host, port, username, password) are correctly set.
  • Invalid Date Format: The node expects ISO 8601 formatted date/time strings with timezone info. Errors occur if the start or end date/time is invalid or missing timezone. Use correct ISO 8601 format like 2023-01-01T09:00:00+08:00.
  • Service Duration Not Found: If the service ID does not exist or has no valid duration, an error is thrown. Confirm the service ID is correct and that the database contains the duration property.
  • Slot Interval Must Be > 0: Setting the slot interval to zero or negative values causes an error. Ensure the interval is a positive integer.
  • Neo4j Connection Failures: Network issues or wrong host/port can cause connection errors. Check connectivity and firewall settings.
  • Timezone Detection Fallback: If the input timezone cannot be detected, the node attempts to fetch the business timezone from the database. If that fails, it defaults to UTC, which may affect slot times.

Links and References

Discussion