1 Chatbot tool
Robin edited this page 2026-11-22 06:21:45 +01:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Chatbot tool and content source

LRob - Calendar can be read by an assistant (chatbot) plugin running on the same site, so that a visitor asking "What's on this weekend?" gets the dates from the calendar itself.

It does so through two WordPress filters that the assistant plugin applies:

Filter What the calendar adds
lrob_chatbot_tools The calendar_events tool: the events between two dates.
lrob_chatbot_sources The lrob_calendar source: each recent or upcoming event as a document to index.

The calendar calls nothing of the assistant plugin. With no assistant on the site, nobody applies these filters and nothing runs.

Turning it on or off

Calendar → Settings → Site assistants → Make the calendar readable by the site's assistants. On by default. Unticked, the calendar declares neither the tool nor the source.

The assistant has its own switch: a tool declared by a plugin stays off until the administrator turns it on in the assistant's settings.

What is given out

Only what any visitor can already see: published events without a password. Drafts, pending, scheduled, private and password-protected events are never returned, by the tool or by the source.

The tool and the source only read. They never create, change or book anything.

The calendar_events tool

Parameters

Name Type Required What it is
from date YYYY-MM-DD yes First day.
to date YYYY-MM-DD yes Last day, included. At most 366 days after from.
category string no Only events of this category, by name or slug. Case and accents don't matter; sub-categories are included.
tag string no Only events with this tag, by name or slug.
search string no Only events whose title, description or place contains this text.
limit integer 1–100 no Maximum number of events. Default 30.

Days are whole days in the site's time zone: to runs until 23:59:59. Two dates given in the wrong order are swapped.

Result

One line per occurrence, soonest first; an event already running on from comes first. Recurring events appear once per date, as on the calendar. Each line gives:

  • the date and time in plain English and in ISO 8601 with the offset;
  • the title;
  • the place (venue, address, postal code and city, country);
  • the categories;
  • a short summary (the excerpt, or the start of the description, 200 characters at most);
  • the address of the event's page, or, when event pages are disabled, of the page that carries the calendar.

The first line says how many events are shown and how many more match. The text stays under the assistant's 20,000-character limit; when events are left out, the last line says how many, and suggests narrowing the dates or filtering.

The addresses are also returned as pages, so the answer can link to them.

Example

A visitor asks, on Friday 20 November 2026: "What's on this weekend?" The assistant calls:

{ "from": "2026-11-21", "to": "2026-11-22" }

and receives:

Events between 2026-11-21 and 2026-11-22, time zone Europe/Paris: 3 shown, 0 more.
- Sat 21 Nov 2026, 10:00–12:00 (2026-11-21T10:00:00+01:00 → 2026-11-21T12:00:00+01:00): Open day — Main hall, 1 Example Street, 45000 Orléans — Category: Visits — Guided tour of the workshops. — https://example.com/events/open-day/
- Sun 22 Nov 2026, all day (2026-11-22): Christmas market — Garden — Category: Markets — Local producers and crafts. — https://example.com/events/christmas-market/
- Sun 22 Nov 2026, 23:30 – Mon 23 Nov 2026, 01:00 (2026-11-22T23:30:00+01:00 → 2026-11-23T01:00:00+01:00): Late show — Theatre — https://example.com/events/late-show/

"When is the next jazz concert?" works the same way, over a wide range:

{ "from": "2026-11-20", "to": "2027-11-19", "category": "jazz", "limit": 1 }

When a category or tag matches nothing, the answer lists the existing ones, so the assistant can try again:

No category matches "sport". Categories: Concerts, Jazz, Markets, Visits.

Speed

One query reads the occurrences the calendar already computed when the event was saved, joined to the events; a second one counts the rest, only when there are more than limit. Category names come in one more query. Nothing is computed per occurrence.

The lrob_calendar content source

The tool finds events by date; the source lets the assistant find them by subject.

Each published event that is running, upcoming, or over for less than 30 days is one document:

  • title: the event's title;
  • body: labelled lines in the site's language (When, Repeats, Where, Category, Price), then the description as the site shows it;
  • address: the event's page, or the page that carries the calendar, or the home page;
  • language: the site's;
  • fingerprint: changes whenever anything shown changes, dates, place and categories included.

A recurring event describes its repeat in words rather than listing dates, which is the tool's job:

When: 3 November 2026 18:00 – 20:00
Repeats: every 2 weeks on Tuesday, until 30 June 2027; except 22 December 2026
Where: Music room, 1 Example Street, 45000 Orléans
Category: Concerts

Saving, unpublishing or deleting an event tells the assistant at once (one notice per request, however many events changed). Changing the setting above, or turning event pages on or off, asks the assistant to read the whole list again.

For developers

Filter Default What it changes
lrob_calendar_chatbot_source_days 30 How many days after its end an event stays in the source.
lrob_calendar_chatbot_calendar_url the first published page with the Calendar block (else the Events List block) The address given for events when event pages are disabled. Return an http(s) address, or '' for none.
// Keep past events in the assistant's knowledge for a year.
add_filter( 'lrob_calendar_chatbot_source_days', fn() => 365 );

// Point visitors to a specific page.
add_filter( 'lrob_calendar_chatbot_calendar_url', fn() => 'https://example.com/agenda/' );