ai.acceptDraft
Accept an AI-drafted reply and deliver it to the guest now. This is a real guest-facing send over the booking channel. Requires confirmation.
Input parameters
| Field | Type | Required | Notes |
|---|---|---|---|
draftId | string | yes | |
bodyOverride | string | no |
Output fields
| Field | Type | Required | Notes |
|---|---|---|---|
messageId | string | yes | |
delivered | boolean | yes | |
rechnungsmail | enum | no | One of: gesendet, gesperrt, keine |
gesperrtSeit | string · nullable | no |
ai.antwortModus
Reads the AI reply switch (off, suggestions only, on) and whether AI replies are enabled for the property. Owner only. Read-only query.
Input parameters
Returns object.
Output fields
| Field | Type | Required | Notes |
|---|---|---|---|
modus | enum | yes | One of: aus, vorschlag, an |
mistralBereit | boolean | yes |
ai.discard_draft
Discard an AI-generated draft reply. Deletes the draft message and logs the discard for trust-ramp acceptance-rate accounting.
Input parameters
| Field | Type | Required | Notes |
|---|---|---|---|
draftId | string | yes |
Output fields
| Field | Type | Required | Notes |
|---|---|---|---|
ok | literal | yes | One of: true |
ai.kiVersandStoppen
“Stop” on an AI suggestion during the recall window: the scheduled automatic send is cancelled and the draft stays as a suggestion. The inbox also calls it on the first keystroke in the draft. Mutation — changes data.
Input parameters
| Field | Type | Required | Notes |
|---|---|---|---|
draftId | string | yes |
Output fields
| Field | Type | Required | Notes |
|---|---|---|---|
gestoppt | boolean | yes | true, wenn ein geplanter Versand gestoppt wurde; false, wenn keiner (mehr) geplant war. |
ai.latestDraftForConversation
Latest draft (AI suggestion) for a conversation, if any. The suggestion-card component fetches this on every drill-down render + after the SSE-driven cache invalidation. Read-only query.
Input parameters
| Field | Type | Required | Notes |
|---|---|---|---|
conversationId | string | yes |
Output fields
The whole object may be null.
| Field | Type | Required | Notes |
|---|---|---|---|
id | string | yes | |
tenantId | string | yes | |
conversationId | string | yes | |
channel | enum | yes | One of: whatsapp, email, hospitable, voice, channex, beds24 |
direction | enum | yes | One of: inbound, outbound |
sender | string · nullable | yes | |
body | string · nullable | yes | |
languageDetected | string · nullable | yes | |
aiLayer | enum · nullable | yes | One of: rule, llm, manual, escalated, auto_received |
aiConfidence | string · nullable | yes | Decimal as string — numeric column, not an IEEE-754 double |
aiReplyToMessageId | string · nullable | yes | |
attachmentUrl | string · nullable | yes | |
attachmentKind | enum · nullable | yes | One of: audio, image, file |
externalMessageId | string · nullable | yes | |
sentReferenceId | string · nullable | yes | |
senderUser | any | yes | Hospitable host account that sent this message ({id,email,name}), stored verbatim in an untyped JSONB column — no Drizzle `$type<>()`, so no fixed shape. |
externalThreadRefs | array of string · nullable | yes | |
subject | string · nullable | yes | |
bodyHtml | string · nullable | yes | |
state | enum | yes | One of: draft, sent |
sentAt | string | yes | |
providerName | string · nullable | yes | |
providerSource | string · nullable | yes | |
deliveryStatus | enum | yes | One of: queued, sent, beobachtet, provider_acked, delivered, read, failed, sync_unknown |
lastReconciledAt | string · nullable | yes | |
providerStatusRaw | any | yes | Last raw provider status payload, kept for debugging only — an untyped JSONB column whose shape is whatever the provider sent. |
invoiceRequested | boolean | yes | |
autoversandFehler | string · nullable | no | |
hatRechnungsabsicht | boolean | no | |
kiGrund | string · nullable | no | |
kiSendenAb | string · nullable | no |
ai.metrics
AI dashboard data for the tenant: current mode (suggest/auto), 7-day acceptance metrics, auto-mode eligibility, current-month spend, and the last 50 invocations, plus this month's model calls per purpose and model (calls, tokens, list-price cost in cents). Read-only.
Input parameters
Returns object.
Output fields
| Field | Type | Required | Notes |
|---|---|---|---|
currentMode | enum | yes | One of: suggest, auto |
acceptance | object | yes | |
acceptance.windowDays | number | yes | |
acceptance.drafted | number | yes | |
acceptance.discarded | number | yes | |
acceptance.autoSent | number | yes | |
acceptance.acceptanceRate | number | yes | |
eligibility | object | yes | |
eligibility.eligible | boolean | yes | |
eligibility.daysSinceFirstDraft | number | yes | |
eligibility.acceptanceRate | number | yes | |
eligibility.drafted | number | yes | |
eligibility.reason | string · nullable | yes | |
spend | object | yes | |
spend.costEurCents | number | yes | |
spend.inputTokens | number | yes | |
spend.outputTokens | number | yes | |
spend.budgetCapCents | number · nullable | yes | |
invocations | array of object | yes | |
invocations.id | string | yes | |
invocations.channel | string | yes | |
invocations.aiLayer | string · nullable | yes | |
invocations.aiConfidence | string · nullable | yes | |
invocations.state | string | yes | |
invocations.body | string · nullable | yes | |
invocations.conversationId | string | yes | |
invocations.sentAt | string | yes | |
aufrufe | array of object | yes | |
aufrufe.anbieter | string | yes | |
aufrufe.modell | string | yes | |
aufrufe.zweck | string · nullable | yes | |
aufrufe.aufrufe | number | yes | |
aufrufe.eingabe | number | yes | |
aufrufe.ausgabe | number | yes | |
aufrufe.kostenCent | number | yes |
ai.previewVoiceStyle
Side-by-side brand-voice preview: composes the same guest message with and without style anchors so the operator can feel the delta before deciding to enable/disable voice training. Mutation — changes data.
Input parameters
| Field | Type | Required | Notes |
|---|---|---|---|
sampleGuestMessage | string | yes |
Output fields
One of 3 shapes, depending on the outcome:
Shape 1
| Field | Type | Required | Notes |
|---|---|---|---|
ok | literal | yes | One of: false |
reason | literal | yes | One of: rate_limited |
Shape 2
| Field | Type | Required | Notes |
|---|---|---|---|
ok | literal | yes | One of: false |
reason | literal | yes | One of: not_enough_anchors |
required | integer | yes | |
current | integer | yes |
Shape 3
| Field | Type | Required | Notes |
|---|---|---|---|
ok | literal | yes | One of: true |
withAnchors | string | yes | |
withoutAnchors | string | yes | |
anchorCount | integer | yes |
ai.setAntwortModus
Changes the AI reply switch: off, suggestions only (drafts) or on (safe answers are sent automatically). Owner only; writes an audit entry with the old and new value. Takes effect only for properties where AI replies are enabled. Mutation — changes data.
Input parameters
| Field | Type | Required | Notes |
|---|---|---|---|
modus | enum | yes | One of: aus, vorschlag, an |
Output fields
| Field | Type | Required | Notes |
|---|---|---|---|
modus | enum | yes | One of: aus, vorschlag, an |
ai.set_mode
Flip tenant AI mode between 'suggest' (operator approves each draft) and 'auto' (eligible drafts auto-send). Going to 'auto' requires the trust-ramp gate (7d soak + 5+ drafts + ≥80% acceptance) — server-side re-check; throws on failure. 'auto' -> 'suggest' is always allowed (kill-switch). Mutating action — requires _confirm: true.
Input parameters
| Field | Type | Required | Notes |
|---|---|---|---|
mode | enum | yes | One of: suggest, auto |
Output fields
| Field | Type | Required | Notes |
|---|---|---|---|
mode | enum | yes | One of: suggest, auto |
ai.update_draft
Save an edited body for an AI-generated draft reply without sending it. The draft stays a draft; accept it later to deliver the edited text. Errors: draft_not_found, not_a_draft.
Input parameters
| Field | Type | Required | Notes |
|---|---|---|---|
draftId | string | yes | |
body | string | yes |
Output fields
| Field | Type | Required | Notes |
|---|---|---|---|
draftId | string | yes |