Neo4j Find Available Slots ResourceOnly icon

Neo4j Find Available Slots ResourceOnly

根據時間和資源可用性查找可用的預約時間段。所有ID格式為 UUID(例如: ecadf8cb-f865-41d2-a1a0-db4311222cdc),Required_Resource_TypeRequired_Resource_Type:所需資源類型的唯一識別碼 (Type ID),格式為 UUID (例如: 17120d3b-7af6-4501-ada6-b2ec7193b6b9),不是資源名稱。,businessId: 要查詢可用時段的商家 ID (UUID),serviceId: 要預約的服務 ID (UUID) (用於獲取時長),startDateTime: 查詢範圍的開始時間 (ISO 8601 格式, 需含時區),endDateTime: 查詢範圍的結束時間 (ISO 8601 格式, 需含時區),intervalMinutes: 生成潛在預約時段的時間間隔(分鐘),requiredResourceTypeId: 所需資源類型的唯一識別碼 (Type ID) (UUID),不是名稱,requiredResourceCapacity: 所需資源數量(預設為 1)。

Neo4j Find Available Slots ResourceOnly

AI-generated

Overview

This node queries a Neo4j database to find available booking time slots for a specified business, service, and required resource type within a given date/time range. It operates in "ResourceOnly" mode, meaning it focuses on resource availability without considering other constraints like staff or location.

Typical use cases include appointment scheduling systems where you need to check when certain resources (e.g., rooms, equipment) are free to be booked for a service of known duration. For example, a spa might want to find all available 15-minute intervals where a massage room (resource) is free to accommodate a massage service.

The node:

  • Validates input parameters including business ID, service ID, date/time range, slot interval, required resource type, and capacity.
  • Connects to Neo4j using provided credentials.
  • Retrieves business hours, service duration, and resource type details.
  • Generates potential time slots within the requested range at the specified interval.
  • Checks each slot for resource availability based on capacity.
  • Returns a list of available slots adjusted to the appropriate timezone.

Properties

Name Meaning
Business ID The unique identifier (UUID) of the business to query available time slots for.
Service ID The unique identifier (UUID) of the service to book; used to determine the service duration.
Start Date/Time The start of the query range in ISO 8601 format with timezone (e.g., 2023-05-01T09:00:00+08:00).
End Date/Time The end of the query range in ISO 8601 format with timezone.
Slot Interval (Minutes) The interval in minutes to generate potential booking slots (minimum 1 minute). Default is 15.
Required Resource Type The unique identifier (UUID) of the required resource type (not the name).
Required Resource Capacity The number of required resources of the specified type needed for the booking. Default is 1.

Output

The node outputs JSON data containing:

  • availableSlots: An array of ISO 8601 datetime strings representing available booking start times.
  • timezone: The timezone string used for the returned slots (detected from query or business settings).
  • mode: Always "ResourceOnly" indicating the mode of operation.
  • serviceId: The service ID used in the query.
  • serviceDuration: Duration of the service in minutes.
  • resourceType: The name of the resource type or its ID if name unavailable.
  • resourceTypeId: The resource type ID.
  • requiredCapacity: Number of resources required.
  • totalCapacity: Total capacity available for the resource type.
  • resourceDescription: Description of the resource type if available.

No binary data output is produced by this node.

Dependencies

  • Requires a Neo4j database connection configured via an API key credential with host, port, username, password, and optionally database name.
  • Uses the neo4j-driver package to connect and run Cypher queries.
  • Relies on helper modules for date/time normalization, timezone detection, and availability checks.
  • Requires proper configuration of the Neo4j instance with relevant nodes and relationships for businesses, services, resource types, and business hours.

Troubleshooting

  • Missing Required Resource Type ID: The node throws an error if the required resource type ID is not provided.
  • Invalid Credentials: Errors occur if Neo4j credentials are incomplete or incorrect.
  • Invalid Date/Time Format: Input dates must be valid ISO 8601 strings with timezone information.
  • No Matching Records: If no business, service, or resource type matches the provided IDs, an error is thrown.
  • Insufficient Resource Capacity: If the total capacity of the resource type is less than the required capacity, the node errors out.
  • Neo4j Connection Failures: Network issues or misconfiguration can cause connection errors.
  • Availability Check Failures: Individual slot checks may fail silently and log debug messages; these do not stop execution but reduce available slots.

To resolve errors:

  • Verify all UUID inputs are correct and exist in the database.
  • Ensure Neo4j credentials are properly set up in n8n.
  • Confirm date/time inputs are correctly formatted and include timezone.
  • Check Neo4j server accessibility and logs for connectivity issues.
  • Review resource capacities and adjust requirements accordingly.

Links and References

Discussion