Neo4j Find Available Slots StaffOnly icon

Neo4j Find Available Slots StaffOnly

根據時間和員工可用性查找可用的預約時間段

Neo4j Find Available Slots StaffOnly

AI-generated

Overview

This node queries a Neo4j database to find available booking time slots for a specific business service, considering the availability of a specified staff member only ("StaffOnly" mode). It is designed to help schedule appointments by checking both business hours and staff availability within a given date/time range.

Common scenarios include:

  • Scheduling client appointments where a particular staff member must be assigned.
  • Finding open time slots for services that require specific staff expertise.
  • Automating booking systems that integrate with Neo4j-based scheduling data.

Practical example:
A salon wants to allow customers to book haircuts with a specific stylist. This node can find all available 15-minute intervals between two dates when that stylist is free to provide the haircut service.


Properties

Name Meaning
Business ID The unique identifier (UUID) of the business for which to query available time slots.
Service ID The unique identifier (UUID) of the service to be booked; used to determine the duration of the service.
Start Date/Time The start of the date/time range to search for available slots, in ISO 8601 format including timezone.
End Date/Time The end of the date/time range to search for available slots, in ISO 8601 format including timezone.
Slot Interval (Minutes) The interval in minutes at which potential booking slots are generated within the date/time range (minimum 1 minute).
Required Staff ID The unique identifier (UUID) of the staff member whose availability should be checked. This is mandatory in "StaffOnly" mode.

Output

The node outputs JSON objects containing:

  • availableSlots: An array of ISO 8601 datetime strings representing the start times of available booking slots that fit the service duration and staff availability.
  • timezone: The timezone string used for the output slots (detected from input or business settings, defaults to UTC).
  • mode: Always "StaffOnly" indicating this mode of operation.
  • serviceId: The service ID used for the query.
  • serviceDuration: Duration of the service in minutes.
  • staffName: The name of the staff member found in the database (or "未知員工" meaning "Unknown Staff" if not found).
  • staffId: The staff ID used for filtering.

The output does not include binary data.


Dependencies

  • Requires a Neo4j database connection configured via an API key credential with host, port, username, password, and optionally database name.
  • Uses Neo4j driver library to connect and run Cypher queries.
  • Relies on helper modules for time normalization, timezone detection, and availability checks.
  • Input date/time values must be in ISO 8601 format with timezone information.
  • The node expects the Neo4j database to have nodes and relationships structured for businesses, services, staff, and their working hours and capabilities.

Troubleshooting

Common Issues

  • Missing Required Staff ID: The node throws an error if the required staff ID is not provided since it operates in StaffOnly mode.
  • Invalid Date/Time Format: If start or end date/time inputs are not valid ISO 8601 strings with timezone, the node will error out.
  • Incomplete Neo4j Credentials: Errors occur if any required connection details (host, port, username, password) are missing or invalid.
  • No Matching Records: If the business, service, or staff member cannot be found or do not match the expected relationships, the node reports no results.
  • Service Duration Missing: If the service duration cannot be retrieved, the node will fail as it cannot calculate slot lengths.

Error Messages and Resolutions

  • "StaffOnly 模式下必須指定 Required Staff ID。"
    Resolution: Provide a valid staff ID parameter.

  • "無效的開始或結束日期/時間格式。請使用 ISO 8601 格式。"
    Resolution: Ensure date/time inputs include timezone and follow ISO 8601 standard.

  • "Neo4j 認證配置不完整。"
    Resolution: Verify all Neo4j credentials are correctly set in n8n.

  • "找不到商家 '${businessId}',或服務 '${serviceId}',或員工 '${staffId}'(可能不存在、不屬於該商家,或無法提供此服務)。"
    Resolution: Confirm IDs exist in the database and relationships are properly established.

  • "無法取得服務 ID: ${serviceId} 的時長"
    Resolution: Check that the service node has a valid duration property.

  • Connection errors such as "Neo4j 連接失敗。"
    Resolution: Check network connectivity and Neo4j server status.


Links and References

Discussion