> ## Documentation Index
> Fetch the complete documentation index at: https://www.spacebring.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Automate everyday operations and scheduled tasks

> Set up agents that charge late fees, chase overdue invoices, apply a flexible cancellation policy, close shop ordering and event registration, post the week's events to the feed, add event attendees to a group chat, and reward members who come often

Some changes have to happen at a set time or right after something happens, such as closing orders for tomorrow's lunch at 5 p.m., adding a late fee to an invoice 10 days after its due date, or closing registration for a workshop 2 days before it starts. An agent makes each change on time, so nobody on your team has to remember it.

![Agent form for late fees with the Schedule trigger and one location selected on Spacebring's coworking space management platform](https://mintcdn.com/spacebring/0h30XGo9thC4Irn9/images/guides-automate-everyday-operations-and-scheduled-tasks-1.png?fit=max\&auto=format\&n=0h30XGo9thC4Irn9\&q=85\&s=e90d1994ee9ea6ecce32cd7b5466946f)

In each run, an agent can:

* Find what needs a change anywhere in your data, such as overdue invoices or this week's events.
* Create, change, and copy items in the areas you allow, such as invoices, credits, bookings, shop products, and events.
* Follow your own rules, such as a fee amount, a notice period, or a cutoff time.
* Post to the feed, and message members in chats.
* Email your team what it changed, or what needs a person's decision.

This guide has examples of [billing tasks](#automate-billing), changes to your [shop and events](#update-your-shop-and-events), and ways to [engage your community](#engage-your-community). Paste their instructions into the agent and change them as you like.

## Set up an agent

1. [Create an agent](/docs/ai-agents/agents.md#create-an-agent) and select the trigger the example shows above its instructions:
   * **Schedule**, shown with its time, such as Daily at 17:00, for a change due at a set time, such as closing orders at 5 p.m.
   * An event, such as Booking canceled, to act right after it happens. The agent runs once for each canceled booking.
2. Turn off **All locations** and select one location in **Locations**.
   * Each example below works for one location, unless it says otherwise. For another location, create another agent.
3. For **Schedule**, set **Repeat**, **Time**, and **Timezone** as you need, such as the schedule the example shows.

![Agent schedule set to run daily at 9:00 AM on Spacebring's coworking space management platform](https://mintcdn.com/spacebring/0h30XGo9thC4Irn9/images/guides-automate-everyday-operations-and-scheduled-tasks-set-up-an-agent.png?fit=max\&auto=format\&n=0h30XGo9thC4Irn9\&q=85\&s=c8a1509b780ec0b9dfb07bd0d31c02f0)

4. In **Instructions**, paste [your change's description](#describe-the-change-you-need), or one of the examples below.
5. Under **Permissions**, turn on the area the example shows, such as Billing permission, and leave the others off. The agent can make changes only in the areas you turn on.
6. Turn on **Enabled** and click **Create**.

> [!WARNING]
>
> An agent makes its changes without asking anyone first, such as issuing an invoice and charging the customer's card. [Test a new agent](#best-practices) before you rely on it.

### Describe the change you need

Write the instructions the way you would brief a colleague who makes the change for you. Say:

* What to find, such as "the invoices in the Issued status whose due date was 10 or more days ago".
* What to change, with exact values, such as "a late fee of 25" or "turn Joining off".
* How the agent can tell it already made the change, such as `Leave out invoices whose internal note contains "Late fee charged".` An agent doesn't remember its earlier runs.
* When to do nothing, such as "If anyone other than the booker canceled the booking, do nothing."
* Whom to tell what it changed or couldn't change, such as "Email the administrator Anna Smith ([anna@example.com](mailto:anna@example.com)) what you changed." The agent can email administrators of your network and customers of its locations.

![Agent instructions for charging a late fee on overdue invoices on Spacebring's coworking space management platform](https://mintcdn.com/spacebring/0h30XGo9thC4Irn9/images/guides-automate-everyday-operations-and-scheduled-tasks-describe-the-change-you-need.png?fit=max\&auto=format\&n=0h30XGo9thC4Irn9\&q=85\&s=cc825832c0cf92e5c339e188223769c0)

## Automate billing

These agents bill customers on time and apply your billing rules, such as late fees and partial refunds, without anyone doing it by hand.

### Charge late fees on overdue invoices

A customer may pay their membership invoice days after its due date, and adding a late fee by hand for each one takes time. You may want to:

* Charge a fixed late fee once an invoice is a set number of days past its due date
* Charge the same fee for every plan
* Add the fee to the customer's next subscription invoice

Daily at 09:00Billing permission

```text title="Instructions" wrap theme={null}
Find the invoices in the Issued status whose due date was 10 or more days ago. Leave out invoices with a payment in progress, invoices whose internal note contains "Late fee charged", and late fee invoices.

For each of them, add an item "Late fee for invoice" followed by the overdue invoice's number, for 25, to the customer's upcoming invoice.

Then add "Late fee charged" to the overdue invoice's internal note, keeping the text already there.
```

An issued invoice can't be changed, so the fee goes on the customer's upcoming invoice. To charge it right away instead, on an invoice of its own, replace the second paragraph with: `For each of them, create an invoice for the same customer with one item, "Late fee for invoice" followed by the overdue invoice's number, for 25. Issue it, and charge it right away to the customer's saved payment method.` This also charges customers with no subscription, who have no upcoming invoice.

### Chase overdue invoices

When Spacebring can't charge an invoice, such as a subscription invoice with a declined card, it sends the customer up to two [payment reminders](/docs/billing/invoices/payment-retries-and-reminders.md), 3 and 6 days later. It sends none for an invoice you issue that nobody tries to pay. A customer may still not pay, and keep using your space. You may want to send:

* Reminders a few days after the due date, such as after 3 and 7 days, with a link to the invoice
* A list for your team of customers whose invoice is long overdue, such as by 14 days, to suspend their access

Daily at 09:00

```text title="Instructions" wrap theme={null}
Find the invoices in the Issued status whose due date was exactly 3, 7, or 14 days ago. Leave out invoices with a payment in progress.

For 3 or 7 days, email the invoice's customer a short, polite reminder with the invoice number, the amount due, and the due date, and link the invoice in the member portal. Write in the customer's language.

For 14 days, email the administrator Tom Brown (tom@example.com) the customer, the invoice number, and the amount due, and say that their access may need to be suspended.
```

> [!NOTE]
>
> An agent can't block a customer's door access, Wi-Fi, or bookings, so it tells your team whom to suspend.

### Apply a flexible cancellation policy

Your cancellation policy may give back part of a booking's price for a late cancellation, such as 50% when a customer cancels 24 to 48 hours ahead. The rescheduling policy refunds a booking in full or not at all, so an agent works out the rest. You may want to:

* Refund in full when a customer cancels early enough, such as 48 hours or more ahead
* Get an email with the refund to give for a later cancellation
* Give back part of the credits for a booking paid with credits

First, turn on [automatic refunds](/docs/billing/payments/refunds.md#configure-automatic-refunds) and set the rooms' **Rescheduling policy** to the notice your policy refunds in full, such as **2 days**. A cancellation with at least that notice is then refunded in full. Set the notice periods and the refund share in the instructions as you need.

Booking canceled

```text title="Instructions" wrap theme={null}
A booking was canceled. Look up the booking, its resource, and how it was paid.

If the booking was free, or anyone other than the booker canceled it, do nothing.

Work out how long before the booking's start it was canceled. If it was 48 hours or more, do nothing: it was refunded in full. If it was less than 24 hours, do nothing: it isn't refunded.

Otherwise, email the administrator Anna Smith (anna@example.com) the customer, the resource, the booking's date and time, when it was canceled, how it was paid, the amount paid, and the refund to give: 50% of the amount paid.
```

When the email arrives, [refund the amount](/docs/billing/payments/refunds.md#issue-refunds-manually-via-spacebring) from the booking's **Payment** section. For a booking paid with **Invoice**, lower its charge with a [credit note](/docs/billing/invoices/credit-notes.md#issue-a-credit-note) once its invoice is issued.

For bookings paid with credits, the agent can give back the credits itself. Turn on the **Customers** permission, and add: `For a booking paid with credits, add the booker 50% of the credits it cost, instead of sending the email.`

## Update your shop and events

These agents make the changes your team would otherwise make by hand at a set time, such as closing orders or event registration.

### Close shop ordering at a cutoff time

Your kitchen may need lunch orders by a set time, such as 5 p.m. the day before, while members can order until the lunch is served. Turning ordering off by hand every day needs someone at that time. You may want to:

* Turn off ordering for tomorrow's lunch at a set time
* Send the kitchen the orders to prepare at the same time

This example works when each day's lunch is its own product, with the date in its title.

Daily at 17:00Shop permission

```text title="Instructions" wrap theme={null}
Find the shop products in the category "Lunch" whose title starts with tomorrow's date, such as "15.07.2026 Lunch".

Turn off ordering for each of them.
```

Members still see tomorrow's lunch in the **Shop**, without the **Order** button. To email your kitchen the orders to prepare at the same time, add a [shop orders report](/docs/guides/send-automatic-reports-and-digests.md#prepare-shop-orders).

### Close event registration before the event

A workshop may need its attendee list a few days ahead, to prepare equipment and materials, while customers can join until it starts. With many workshops, turning off joining for each one by hand is easy to forget. You may want to:

* Close joining a set time before each event starts, such as 2 days
* Close it only for workshops, and keep it open for other events

Daily at 09:00Events permission

```text title="Instructions" wrap theme={null}
Find the events that start 2 days from today and have Joining turned on.

Turn Joining off for each of them.
```

Customers who joined keep their tickets, and others no longer see the **Join** button. To add a late attendee yourself, turn **Joining** back on first. To close joining only for workshops, start the instructions with: `Find the events with "Workshop" in their title that start 2 days from today and have Joining turned on.`

## Engage your community

These agents bring members together and thank them for coming back.

### Post the week's events to the feed

Members may miss the events you publish, and in a network with several locations, they may never see the events of the others. You may want to:

* Post the week's events every Monday
* Show the events of all your locations in one post, with a link to each
* Post a reminder on a set day, such as before a monthly event

Weekly on Monday at 09:00

```text title="Instructions" wrap theme={null}
Find the events that start this week, from Monday to Sunday, leaving out canceled events. If there are none, do nothing.

Publish a feed post that starts with "This week's events". List each event with its date, time, and venue, and link it in the member portal. Keep it short and friendly, and write in the language of the events' descriptions.
```

To show the events of all your locations in every location's feed, keep **All locations** on, and add: `Include the events of every location, grouped by location, and publish the post in each location's feed.`

> [!NOTE]
>
> A member can open an event of another location only when the event is visible to them, such as to network members or the public.

### Add event attendees to a group chat

Attendees of an event may want to meet each other, while adding each of them to a group chat by hand takes time. You may want to:

* Start a group chat for an event once a second person joins it
* Add everyone who joins later to the same chat
* Welcome attendees and invite them to introduce themselves

Event ticket paid

```text title="Instructions" wrap theme={null}
A ticket for an event was paid. Look up the event and its attendees with an active ticket.

Find your group chat for this event, titled with the event's title and date. If there is one, add the ticket's attendee to it, unless they are already in it.

If there is none and the event has at least 2 attendees, create a group chat titled with the event's title and date, with every attendee. Then post a short message in it: welcome everyone, name the event and its date, and invite them to introduce themselves. Write in the language of the event's description.

If the event has only 1 attendee, do nothing. They join the chat when it starts.
```

To follow the chat yourself, add: `Add the administrator Anna Smith (anna@example.com) to the group too.`

> [!NOTE]
>
> Members see the group chat only while **Chats** is turned on in **Network settings** > **Chats**. An agent can't remove anyone from a group chat, so an attendee who cancels their ticket stays in it until they leave.

### Reward members who come often

A member who comes often may get nothing for it, while a small reward, such as a free coffee on their 10th visit, shows them you noticed. You may want to:

* Give a free coffee on a set visit, such as every 10th
* Give credits on every 10th booking of a meeting room
* Give a discount after a set number of shop orders, such as every 10th lunch

First, [create a coupon](/docs/catalog/discounts.md#create-coupons) for the reward, such as "Free coffee", with 100% off the shop product "Coffee".

Checked inBilling permission

```text title="Instructions" wrap theme={null}
A customer checked in. If the check-in is for an event or a visit, do nothing.

Count the customer's check-ins in this location, leaving out those for events and visits. If the count isn't a multiple of 10, do nothing.

Otherwise, create a promo code for the coupon "Free coffee" that can be redeemed once and expires in 30 days. Make the code from the customer's first name and the count, such as ANNA10.

Message the customer in chats: thank them for coming in so often, name the number of visits, and give them their reward. Write in the customer's language.
```

To give credits instead, turn on the **Customers** permission in place of **Billing**, and replace the third paragraph with: `Otherwise, add the customer 2 credits that expire in 30 days.` Credits must be [turned on](/docs/billing/credits-and-day-passes/credits.md#set-up-credits) in the location. To reward something else, such as every 10th booking of a meeting room or every 10th lunch order, select **Booking paid** or **Order completed** instead, and say in the instructions what to count.

> [!NOTE]
>
> Members see the message only while **Chats** is turned on in **Network settings** > **Chats**.

## Best practices

* Test a new agent before it makes real changes. Add a line such as `Don't change anything. Reply with the changes you would make.`, set its time to the next quarter of an hour, and read the [run](/docs/ai-agents/agents.md#review-runs). Remove the line once the changes look right.
* Ask the agent to report what it changed, such as `Then email the administrator Anna Smith (anna@example.com) a list of what you changed.` Your team sees it without opening the runs.
* Before you turn on an agent, make sure the features its example uses are on, such as Chats or credits. A change the agent can't make appears in its run with the error, while the run itself shows **Completed**.

## FAQs

> **Can an agent undo its changes?**
>
> No. Open the agent on the **Network settings** > **AI & Agents** page and click the run: it lists every change the agent made. Change each one back yourself, such as by [voiding an invoice](/docs/billing/invoices/void-or-delete.md) it issued.

> **Why didn't the agent make the change?**
>
> Open the agent on the **Network settings** > **AI & Agents** page and check its [runs](/docs/ai-agents/agents.md#review-runs):
>
> * **Completed** — open the run to read the agent's reply. If it changed nothing, the reply says why, such as a rule in your instructions, a permission that is turned off, or a feature that is turned off in the location.
> * **Failed** — the run shows the error.
> * **Skipped** — your network's balance ran out. Runs resume once it's topped up.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.