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 |
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.latestDraftForConversation
Ai: latest draft for conversation. Read-only query. See the input schema for argument details.
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 |
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. 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 |
ai.previewVoiceStyle
Ai: preview voice style. Mutation — changes data. See the input schema for argument details.
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.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 |