Rylvo
Blog

How to Save Chatbot Conversations to Your Own Database

Save every chatbot conversation to Postgres, Supabase, MySQL, MongoDB or a webhook: pick a table layout, keep test data apart, and replay failed saves.

In this articleOverview

To save chatbot conversations to your own database, connect the bot to a destination (a direct database connection or an HTTPS webhook), pick a table layout, create the tables once, and let each message, collected answer and session summary arrive as a row. Keep test chats in separate tables, and replay any save that fails.

Key takeaways

  • Your database becomes the permanent record; the chatbot platform keeps only a short working copy for its own tools.
  • Rylvo writes directly to 8 databases (PostgreSQL, Supabase, Neon, MySQL, PlanetScale, Turso, MongoDB, Redis) or posts JSON to a webhook.
  • Saves never slow a reply down: each event is queued and delivered within about 15 minutes, retried up to 10 times, then kept for replay.
  • Test chats are delivered only after an admin allows Test deliveries in Conversation Storage Settings; until then they wait as pending saves and nothing is sent to your database or webhook. Once allowed, they go to _test tables or a separate database, so they never mix with live data. Test events count toward your monthly allowance like live ones.
  • Available on Lite ($40/month) and up, and in the 7-day Pro trial. Prices checked on 2026-11-17.

Why save chatbot conversations outside the platform

Many chatbot tools keep transcripts in their own database and give you a dashboard and an export option. That works until you need one of these:

  • Your own retention rule. Retention rules differ by business: a support team might keep transcripts for a year, a regulated firm for longer, and a shop might want them gone in weeks. GDPR's storage-limitation principle (Article 5(1)(e)) says personal data must be kept in identifiable form no longer than is necessary for the purposes it was collected for. You set and document that period for your own business, and a database you control lets you enforce it with a scheduled delete.
  • Joins with your own data. A conversation is far more useful next to the CRM record, the order or the support ticket it belongs to. That needs SQL in your database, not a CSV exported once a month.
  • Leaving cleanly. If the data already lives in your database, the transcript history stays with you when you change platforms. You keep every conversation saved since the connection was switched on.

If all you want is each new lead in a spreadsheet or CRM, you may not need a database at all: a lead webhook to Zapier, Make or n8n is less work, because it needs no tables. The lead generation chatbot guide and the chatbot webhooks guide cover that path. Conversation storage is for when you want the full record.

Webhook or direct database: which to pick

WebhookDirect database
You provideAn HTTPS endpointA connection string
Rylvo sendsOne JSON POST per eventOne row (or document) per event
Best whenYou already have an API, a pipeline, or a warehouse loaderYou want rows in Postgres, MySQL or MongoDB with no code to write
Credentials leave your side?No, only a shared secret or tokenYes, a database login (an insert-only user works once the tables exist)
Warehouses (BigQuery, Snowflake)Yes, load from your endpointNo direct writer
AuthNone, API key header, Bearer token, or HMAC signatureThe database's own login

A practical rule: if you would rather not give a vendor a database password, use the webhook. If you want the shortest path to queryable rows, use a direct connection with a dedicated database user.

Credentials you enter are encrypted at rest and never shown again after you save them. Webhook URLs must be HTTPS, and addresses that point at private or internal networks are refused.

What gets saved: the 9 events

Every save is an event. A new connection receives 8 of them by default; "Tracked detail changed" is opt-in, because it can fire several times in one turn and each event counts toward your monthly allowance.

EventWhat it carriesTable
Conversation startedThe first turn of each conversation — its title, model and channel.conversations
MessageEvery message from the customer and from the bot, with model, tokens and latency.messages
Answer collectedAn answer the bot collected — an email, an order number …messages
Checkpoint reachedA goal the conversation reached — qualified, booked, resolved …messages
Session summaryOne row when a session ends: why it ended, how many turns, the summary.sessions
Conversation endedThe conversation was closed or deleted.conversations
Conversation archivedSomeone archived the conversation in the dashboard.conversations
Handed to another agentIn an agent group, one agent passed the conversation to another.messages
Tracked detail changed (opt-in)A tracked detail changed — a serial number read from a photo, an order status a connector returned, a counter … with who changed it and, for a sensitive one, no value.messages

You can untick any event on a connection. A common setup for analytics is messages, collected answers and session summaries only.

Answer-collected events are stored in the messages table (the default template has field_key, field_label, field_value and field_redacted columns). Check what lands in your own tables before relying on them for sensitive fields.

Pick a table layout

Rylvo ships 10 templates. Each one maps the event fields to column names, and you can rename or skip any column.

TemplateShapeUse it for
Default (Relational)Three tables: conversations, messages, sessionsPostgres, MySQL, Supabase, Neon, PlanetScale, Turso
Flat MessagesOne wide table, one row per eventSimple reporting
MongoDB DocumentOne document per event, three collectionsMongoDB
MinimalTranscript only: who said what, whenArchives
Field Collection AnalyticsOne row per collected answerLead and form analysis
Checkpoint FunnelOne row per goal reachedConversion funnels
Session AnalyticsOne session-centred table: every event with its session, customer and status, plus a summary row when each session endsReporting on sessions rather than reading transcripts
Tracked Details LogOne row per tracked-detail changeAudit trails of changing values
Redis StreamOne list per conversation, one JSON event per element (newest last), capped at the most recent 10,000 eventsRedis connections; no tables to create
BigQuery-Ready FlatFlat shape with warehouse typesLoading webhook events into a warehouse yourself

Note the last one: Rylvo does not write to BigQuery, Snowflake or S3. The template gives you a ready table definition for a loader you run.

The default schema, for Postgres

This is a shortened version of the Default (Relational) messages table. The full template also has columns for attachments, collected fields and checkpoints.

CREATE TABLE IF NOT EXISTS rylvo_messages (
  event_id             TEXT PRIMARY KEY,   -- stable per event: retries never duplicate
  event_type           TEXT,
  conversation_id      TEXT NOT NULL,
  bot_id               TEXT NOT NULL,
  end_user_id          TEXT,
  session_id           TEXT,
  message_id           TEXT,
  role                 TEXT,               -- user | assistant
  content              TEXT,
  created_at           TIMESTAMPTZ,
  model_used           TEXT,
  latency_ms           INTEGER,
  total_tokens         INTEGER,
  guardrail_triggered  BOOLEAN,
  operator_authored    BOOLEAN,            -- a teammate typed it, not the AI
  metadata             JSONB
);
CREATE INDEX IF NOT EXISTS idx_rylvo_messages_conv
  ON rylvo_messages(conversation_id, created_at);

The tables are append-only: each event is a new row, and the current state of a conversation is its latest row. Because event_id is the primary key, a retried delivery is ignored instead of inserted twice.

Rylvo never creates or changes a table by itself. On a SQL connection, the dashboard shows the exact CREATE TABLE statements for your database's dialect; an admin can run them with the saved credentials, or copy them into your own migration tool.

A query you can run on day one

The conversations from the last week with the most customer messages, a quick way to find the ones that went in circles:

SELECT conversation_id,
       COUNT(*) FILTER (WHERE role = 'user')      AS customer_messages,
       COUNT(*) FILTER (WHERE operator_authored)  AS teammate_messages,
       MAX(created_at)                            AS last_message_at
FROM rylvo_messages
WHERE event_type = 'message_appended'
  AND created_at > now() - interval '7 days'
GROUP BY conversation_id
ORDER BY customer_messages DESC
LIMIT 20;

The webhook payload

In webhook mode each event is one POST with a JSON body like this (a reply from the bot):

{
  "event": "message_appended",
  "orgId": "org_123",
  "botId": "bot_456",
  "conversationId": "conv_789",
  "payload": {
    "messageId": "msg_abc",
    "role": "assistant",
    "content": "We're open until 6 pm on Saturdays.",
    "metadata": {
      "channel": "widget",
      "sessionId": "sess_01",
      "model": "openai/gpt-6-luna",
      "totalTokens": 512,
      "guardrailsTriggered": 0
    }
  },
  "emittedAt": "2026-11-17T08:00:00.000Z",
  "eventId": "8f2c1e0b9a7d4c3e",
  "traceId": "trace_42",
  "source": "channel",
  "isTest": false
}

Return any 2xx status to accept it. Every request also carries an Idempotency-Key header equal to eventId; store it and skip any event you have already seen.

Verify the HMAC signature

With HMAC auth, Rylvo signs timestamp + ":" + raw body with your shared secret and sends X-Rylvo-Signature: sha256=<hex> and X-Rylvo-Timestamp. A Node.js check:

import crypto from "node:crypto";

export function isFromRylvo(rawBody, headers, secret) {
  const ts = headers["x-rylvo-timestamp"];
  const sent = headers["x-rylvo-signature"] || "";
  if (!ts || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false; // reject replays
  const expected = "sha256=" + crypto
    .createHmac("sha256", secret)
    .update(`${ts}:${rawBody}`)
    .digest("hex");
  return sent.length === expected.length &&
    crypto.timingSafeEqual(Buffer.from(sent), Buffer.from(expected));
}

Verify against the raw request body, before any JSON parsing changes it.

Keep test conversations apart

When you try a bot in the dashboard, those chats are test traffic, and they should never land next to real customers' conversations. Test delivery is off by default: until an admin allows Test deliveries in Conversation Storage Settings, test chats wait as pending saves and nothing is sent to your database or webhook. Once it is allowed, Rylvo separates them at the destination:

  • SQL and Redis connections write test events to the same tables with a _test suffix (rylvo_messages_test).
  • MySQL, PlanetScale and MongoDB can instead send test events to a separate database you name.
  • Webhooks use a separate Test URL, which must first echo back a verification challenge (a random value Rylvo sends in a JSON POST) before it receives any test events. Each test request is marked with "isTest": true and an X-Rylvo-Environment: test header.

Connections, queues and history are kept separately for Test and Production, so a test run never hides a real error in the delivery history. Because a connection belongs to one environment, check how it is created in Test before relying on a single connection for both; the plan's connection limit counts Test and Production together. Test events count toward your monthly allowance like live ones. The Test vs Production guide explains how the same split works for prompts, knowledge and releases, and the Environments page shows it in the product.

Delivery, retries and replay

Saving never sits in the path of a reply. The order of events is:

  1. The bot answers the visitor.
  2. The events for that turn are written to a queue.
  3. On the next delivery run (within about 15 minutes), queued events are sent to every connection that accepts them.
  4. A failed event stays queued and is tried again on each run.
  5. After 10 failed tries it moves to Failed events, with the error message. Fix the cause (a wrong password, a missing column, an endpoint returning 500) and replay one event or all of them. Failed events are kept for 30 days.

You can also choose when events go out, per bot or for the whole workspace: As they happen (the default; each event goes out on the next delivery run, within about 15 minutes), In batches (released when enough events are waiting or the oldest has waited long enough), or Only when you sync, which holds everything until someone presses Sync now.

In the dashboard, the Conversation Storage area is split into Overview, Live saves, Delivery history and Failed events for monitoring, a page per connection, and Tables & columns and Settings for configuration.

Plans, limits and cost

FreeStarterLitePro
Connections0015
Events included per monthnonenone250,0001,000,000
Beyond the allowancenonenone$0.50 per 1,000$0.50 per 1,000
Rylvo's own working copy7 days14 days14 days90 days

Prices checked on 2026-11-17; the pricing page is always current. Lite is $40 a month and Pro is $100. Enterprise limits are set by contract.

Two details matter in practice:

  • Overage comes from the prepaid wallet. Events beyond the monthly allowance are paid per 1,000 from the wallet, not from your plan or your AI replies. If the wallet cannot cover them, those extra events are not saved, so top it up or narrow the event list before a busy month.
  • Rylvo's working copy is temporary. Rylvo keeps its own copy of conversations for the window above so traces and quality tools keep working; your database copy is the one that lasts. There is no backfill: a new connection receives events from the moment it is switched on, so connect early.

What does the allowance mean in conversations? A turn usually produces two message events (the visitor's message and the reply), plus a session summary when the session ends. Add the conversation-started event and a ten-turn conversation is roughly 22 events, so 250,000 events is on the order of 11,000 such conversations a month. Unticking events you do not need stretches it further.

How to save chatbot conversations to your database in six steps

  1. Pick the destination. Create a dedicated database user, or stand up an HTTPS endpoint. Rylvo only inserts rows, so after the tables exist the user needs only INSERT. If you let the dashboard create the tables, the user also needs CREATE for that first step. Otherwise run the CREATE TABLE statements yourself with an admin login and keep the connection user insert-only.
  2. Add a connection. Choose webhook or direct database, paste the URL or connection string, and choose the auth method. Test the connection before saving.
  3. Choose bots and events. Leave the bot list empty to save every bot, or name specific ones. Start with the default events.
  4. Pick a template and create the tables. Run the generated CREATE TABLE statements, including the _test copies.
  5. Turn on Test delivery, then send a test chat. In Conversation Storage Settings, check that Test delivery is on for the workspace. While it is off, test chats wait as pending saves and nothing is sent to your database or webhook. Then talk to the bot in the dashboard and check that rows appear in the test tables, not the live ones.
  6. Go live and watch. After real conversations start, check Delivery history once, then let Failed events tell you when something breaks.

If someone asks you to erase their data, Rylvo's Audience area covers the copy Rylvo holds. Rylvo only inserts rows into your database and never deletes from it, so you must erase that person's rows yourself: filter on end_user_id (or conversation_id) and delete them in your database, and in any warehouse your webhook loads. The GDPR checklist for chatbots lists what to ask of any vendor, including us. Security details are on the security page, and setup reference is in the docs.

When another approach fits better

  • You only need leads. A lead webhook to your CRM is less work than a full conversation store.
  • You need a warehouse table updated directly. Rylvo has no BigQuery, Snowflake or S3 writer; you would run a small loader behind the webhook.
  • You need last year's history. Events start when the connection starts; there is no import of past conversations.

Frequently asked questions

Which databases can a chatbot save conversations to directly?

Rylvo writes directly to 8 databases: PostgreSQL, Supabase, Neon, MySQL, PlanetScale, Turso, MongoDB and Redis. For anything else, including BigQuery or Snowflake, send events to a webhook and load them from there.

Does saving conversations to my database slow down the chatbot's replies?

No. The reply never waits for the save. Each event is queued and sent on the next delivery run, within about 15 minutes.

What happens if my database is down when an event is sent?

The event stays queued and is tried again on each delivery run. After 10 failed tries it moves to Failed events, where you can read the error and replay it once the cause is fixed. Failed events are kept for 30 days.

How do I keep test conversations out of my production tables?

After an admin allows Test deliveries in Conversation Storage Settings, test chats go to tables with a _test suffix in the same database, or to a separate database on MySQL, PlanetScale and MongoDB. Until then they wait as pending saves and nothing is sent. A webhook connection uses a separate Test URL that must first echo a verification challenge.

Which plan do I need to save conversations to my own database?

Lite ($40 a month) and up. Lite includes 1 connection and 250,000 events a month; Pro ($100 a month) includes 5 connections and 1,000,000 events. The 7-day Pro trial includes it. Free and Starter do not.

Will a retried event create duplicate rows?

No. Every event carries a stable event ID. The SQL templates use it as the primary key, the MongoDB driver upserts on it, and webhooks receive it as an Idempotency-Key header, so a retry overwrites or is ignored instead of duplicating.

Build your first agent on the free plan.