Build a booking request page for a small business and publish it online
Build and publish a small-business booking request page on DeepSpace: open time slots, stored requests the owner confirms or declines, no double bookings, and email notifications without a separate form-to-email service.
On this page
Yes. On DeepSpace, a booking request page is one app: a public page that lists open time slots and takes requests, a sign-in-only page where the owner confirms or declines them, and a scheduled job that emails the owner about new requests. Requests are stored in the app's own database, so no separate form-to-email service, hosting account, or database account is needed. The owner's DeepSpace account (GitHub or Google sign-in) is the one account involved. Payments are not part of this build.
Checked against: published SDK deepspace@0.43.0 (changelog), docs read on October 29, 2026. The code below follows the documented APIs and was not run for this page.
Questions to ask the person#
- What do people book: a call, a visit, a consultation? How long does it last?
- Which days and times can people request? Should a slot disappear once it is booked?
- What should visitors fill in? (Name and email are the usual minimum; a short note is optional.)
- Which email address should hear about new requests?
- Should visitors get an email when their request is confirmed or declined?
- Will they take payments or deposits? If yes, that is a separate step a person has to set up.
How the app is shaped#
| Collection | Who can read | Who can write | Purpose |
|---|---|---|---|
slots |
Everyone | Owner (admin) | Times the owner offers, each open or booked |
requests |
Owner (admin) | Visitors create; owner updates | One row per booking request, status pending, confirmed or declined |
bookings |
Owner (admin) | Owner | One row per confirmed slot; uniqueOn: ['slotId'] blocks a double booking |
A request is not a booking. Several visitors can request the same slot at the same time, and every request is stored. A slot becomes a booking when the owner confirms one request. The bookings collection's uniqueness rule refuses a second confirmation for the same slot, even if two people confirm at once in different browser tabs.
Steps#
1. Sign in and scaffold#
Signing in uses the person's own GitHub or Google account in a browser. Confirm with your user before signing in on their behalf, and use the account they want to own the app; the app owner is the admin who sees the requests.
npx deepspace auth login
npm create deepspace@latest acme-bookings
cd acme-bookings
App names are global and become <name>.app.space. Choose a distinctive one.
2. Define the collections#
// src/schemas/booking-schemas.ts
import type { CollectionSchema } from "deepspace/schema";
const closed = { read: false, create: false, update: false, delete: false };
export const slotsSchema: CollectionSchema = {
name: "slots",
columns: [
{
name: "startsAt",
storage: "text",
interpretation: { kind: "datetime" },
required: true,
},
{
name: "minutes",
storage: "number",
interpretation: "plain",
required: true,
},
{
name: "status",
storage: "text",
interpretation: { kind: "select", options: ["open", "booked"] },
default: "open",
},
],
permissions: {
"*": { read: true, create: false, update: false, delete: false },
viewer: { read: true, create: false, update: false, delete: false },
member: { read: true, create: false, update: false, delete: false },
admin: { read: true, create: true, update: true, delete: true },
},
};
export const requestsSchema: CollectionSchema = {
name: "requests",
columns: [
{
name: "slotId",
storage: "text",
interpretation: "plain",
required: true,
},
{ name: "name", storage: "text", interpretation: "plain", required: true },
{
name: "email",
storage: "text",
interpretation: { kind: "email" },
required: true,
},
{ name: "note", storage: "text", interpretation: "plain" },
{
name: "status",
storage: "text",
interpretation: {
kind: "select",
options: ["pending", "confirmed", "declined"],
},
default: "pending",
},
{
name: "ownerNotified",
storage: "number",
interpretation: { kind: "boolean" },
default: false,
},
{
name: "visitorNotified",
storage: "number",
interpretation: { kind: "boolean" },
default: false,
},
],
uniqueOn: ["slotId", "email"],
permissions: {
"*": {
...closed,
create: true,
writableFields: ["slotId", "name", "email", "note"],
},
viewer: {
...closed,
create: true,
writableFields: ["slotId", "name", "email", "note"],
},
member: {
...closed,
create: true,
writableFields: ["slotId", "name", "email", "note"],
},
admin: { read: true, create: true, update: true, delete: true },
},
};
export const bookingsSchema: CollectionSchema = {
name: "bookings",
columns: [
{
name: "slotId",
storage: "text",
interpretation: "plain",
required: true,
},
{
name: "requestId",
storage: "text",
interpretation: "plain",
required: true,
},
],
uniqueOn: ["slotId"],
permissions: {
"*": closed,
viewer: closed,
member: closed,
admin: { read: true, create: true, update: true, delete: true },
},
};
Register all three in src/schemas.ts next to usersSchema and settingsSchema. writableFields stops a visitor from setting status or the notification flags. uniqueOn: ['slotId', 'email'] refuses a second request for the same slot from the same email address. Signed-out visitors connect with the viewer role; the scaffold's (app)/_layout.tsx already mounts <RecordProvider allowAnonymous>.
3. Build the public request page#
Put it at src/pages/(app)/book.tsx so it has the data providers but no sign-in gate.
import { useState } from "react";
import { useQuery, useMutations } from "deepspace";
type Slot = { startsAt: string; minutes: number; status: "open" | "booked" };
type Req = { slotId: string; name: string; email: string; note?: string };
export default function BookPage() {
const { records: slots, status } = useQuery<Slot>("slots", {
where: { status: "open" },
orderBy: "startsAt",
});
const { createConfirmed } = useMutations<Req>("requests");
const [slotId, setSlotId] = useState("");
const [form, setForm] = useState({ name: "", email: "", note: "" });
const [result, setResult] = useState<string | null>(null);
async function submit() {
try {
await createConfirmed({ slotId, ...form });
setResult(
"Request sent. You will hear back by email once it is confirmed.",
);
} catch (e) {
setResult(
String(e).includes("Duplicate")
? "You already requested this time."
: "That did not go through. Please try again.",
);
}
}
if (status === "loading") return <p>Loading times…</p>;
if (result) return <p>{result}</p>;
// Render the open slots as choices, the three fields, and a submit button that calls submit().
}
createConfirmed waits for the server, so the visitor sees "Request sent" after the request is stored, not before. Repeated clicks with the same email for the same slot hit the uniqueness rule instead of creating duplicates.
4. Build the owner's page#
Put it at src/pages/(app)/(protected)/requests.tsx so it requires sign-in. Visitors and ordinary signed-in members cannot read requests; they see an empty list.
import { useQuery, useMutations } from "deepspace";
export default function RequestsPage() {
const { records } = useQuery("requests", {
where: { status: "pending" },
orderBy: "createdAt",
});
const requests = useMutations("requests");
const bookings = useMutations("bookings");
const slots = useMutations("slots");
async function confirm(r) {
try {
await bookings.createConfirmed({
slotId: r.data.slotId,
requestId: r.recordId,
});
} catch {
alert("This time is already booked. Decline this request instead.");
return;
}
await requests.put(r.recordId, { status: "confirmed" });
await slots.put(r.data.slotId, { status: "booked" });
}
const decline = (r) => requests.put(r.recordId, { status: "declined" });
// List each pending request with its time, name, email and note, plus Confirm and Decline buttons.
}
The owner adds and removes times on the same page with useMutations('slots').
5. Email the owner about new requests#
Scheduled jobs run as the app owner, so they can read private requests and send email through the built-in email/send integration. Sends are billed to the owner's DeepSpace credits. The sender must be <app-name>@app.space.
// src/cron.ts
import type { CronTask } from "deepspace/worker";
import { buildCronContext } from "deepspace/worker";
const FROM = "Acme Bookings <acme-bookings@app.space>";
const OWNER_INBOX = "owner@example.com"; // the address from the questions above
export const tasks: CronTask[] = [
{ name: "booking-emails", intervalMinutes: 10 },
];
export async function runTask(name: string, env: Env): Promise<void> {
if (name !== "booking-emails") return;
const ctx = buildCronContext(
env,
env.OWNER_USER_ID,
`app:${env.DEEPSPACE_APP_ID}`,
);
for (const r of await ctx.records.query("requests", {
where: { ownerNotified: false },
})) {
await ctx.integrations.call("email/send", {
from: FROM,
to: OWNER_INBOX,
reply_to: r.data.email,
subject: `New booking request from ${r.data.name}`,
text: `${r.data.name} (${r.data.email}) requested a time. Review it at /requests.\n${r.data.note ?? ""}`,
});
await ctx.records.update("requests", r.recordId, { ownerNotified: true });
}
for (const r of await ctx.records.query("requests", {
where: { visitorNotified: false },
})) {
if (r.data.status === "pending") continue;
await ctx.integrations.call("email/send", {
from: FROM,
to: r.data.email,
reply_to: OWNER_INBOX,
subject: `Your booking request was ${r.data.status}`,
text: `Your request has been ${r.data.status}.`,
});
await ctx.records.update("requests", r.recordId, { visitorNotified: true });
}
}
Drop the second loop if the person does not want visitor emails.
6. Deploy and verify#
git add -A && git commit -m "Booking request page"
npx deepspace deploy
npx deepspace logs --search cron
The app is live at https://<app-name>.app.space. Before handing it over: add two slots as the owner, request one from a signed-out browser, confirm the request appears on the owner's page, confirm it, and check that the slot leaves the public list. Send the same request twice to see the duplicate message. Within ten minutes, npx deepspace logs --search cron should show [cron] booking-emails ok, and the owner inbox should have the email.
Common failures and fixes#
| Symptom | Cause | Fix |
|---|---|---|
| Public page is blank for signed-out visitors | RecordProvider without allowAnonymous, or the page is outside src/pages/(app)/ |
Keep the scaffold's allowAnonymous and put the page under (app)/ |
| Visitor's submit is refused as a permission error | No create: true for viewer, or the form sends a field outside writableFields |
Grant create to viewer and '*'; send slotId, name, email and note, nothing else |
| Owner sees no requests | The signed-in account is not the app owner or an admin | Sign in with the account that deployed the app, or have the owner promote the user with useUsers().setRole(userId, 'admin') |
| Two confirmations for one slot | Confirming without the bookings uniqueness check |
Create the bookings row with createConfirmed first and stop if it is refused |
| No emails arrive | Sender is not <app-name>@app.space, or the schedule has not run |
Use the exact sender; check npx deepspace logs --search cron for ok or failed lines |
Deploy refused with dirty_worktree |
Uncommitted changes | Commit, then deploy again |
What to tell the person when it is live#
- The public link to share:
https://<app-name>.app.space/book. - Where they manage requests:
https://<app-name>.app.space/requests, signed in with the account that owns the app. - A request is not a booking until they press Confirm. Confirming removes the time from the public page.
- They get an email for each new request within about ten minutes, and replying goes straight to the visitor.
- Visitor contact details stay off the public page; visitors cannot read other people's requests.
- Payments, calendar sync and reminders are not included; ask for them as a separate change.
Available today and planned#
Available today, in the published SDK: public pages with anonymous visitors, server-enforced permissions, writableFields, uniqueOn, scheduled jobs, email/send from <app-name>@app.space, and deploys to <app-name>.app.space under a DeepSpace account that signs in with GitHub or Google.
Planned: agents creating their own DeepSpace account without a human sign-in. It is in testing on staging and is not enabled in production; see Full-stack apps without a human in the loop. Payments and other legal actions will still require a person.
Building this for a business? See deep.space/enterprise.