Skip to main content

Knowledge > Runbooks > Chatbot Ops > Add Chatbot for a New Church

Add Chatbot for a New Church

Provision the ChurchWiseAI chatbot for a church that has purchased a chat or bundle subscription. After this runbook, the church will have a working chatbot and the embed code to add it to their website.

Schema Warning — Verified 2026-03-25

IMPORTANT: The actual organization_settings table schema was verified against production on 2026-03-25 and differs significantly from earlier assumptions. Key findings:

  • The primary key for joining is organization_id (UUID), NOT church_id
  • There is NO pro_website_mode column — it does not exist in this table
  • There is NO enabled column, NO tier column, NO theological_lens_id column, NO greeting_message column, NO chatbot_name column as top-level columns
  • Chatbot config (tone, language, theological lens, welcome message, etc.) lives inside the chatbot_config JSONB column
  • Agent configuration lives in agent_config, agent_tool_config, business_agent_config, business_tool_config JSONB columns

Actual columns in organization_settings (as of 2026-03-25):

ColumnTypeNullable
iduuidNO
organization_iduuidNO
brandingjsonbYES
security_settingsjsonbYES
notification_preferencesjsonbYES
feature_flagsjsonbYES
integration_settingsjsonbYES
compliance_settingsjsonbYES
created_attimestamptzYES
updated_attimestamptzYES
account_settingsjsonbNO
chatbot_configjsonbNO
widget_primary_colortextYES
widget_positiontextYES
agent_configjsonbYES
doctrinal_overridesjsonbYES
agent_tool_configjsonbYES
business_agent_configjsonbYES
business_tool_configjsonbYES

The steps below have been updated to reflect the actual schema. The organization_id value — and the link between a church and their organization_settings row — needs to be confirmed against the premium_churches or churches table join pattern. Agents should query the actual row before writing any SQL updates.

Prerequisites

  • Church has an active subscription in premium_churches with a chat-enabled plan
  • Church UUID from the churches table
  • Supabase MCP or direct DB access
  • Church denomination (for auto-selecting theological lens)

Steps

  1. Verify the subscription is active and includes chatbot:

    SELECT pc.church_id, pc.plan, pc.status, pc.tier, c.name, c.denomination_id
    FROM premium_churches pc
    JOIN churches c ON c.id = pc.church_id
    WHERE pc.church_id = '[uuid]';

    Confirm status = 'active' and plan includes chat (e.g., starter_chat, pro_chat, suite_chat, starter_bundle, pro_bundle, suite_bundle).

  2. Determine the theological lens from the church's denomination:

    SELECT id, name, tradition
    FROM sai_theological_lenses
    ORDER BY name;

    Match the church's denomination to the closest tradition. Use universal (id=1) if uncertain.

  3. Check if organization_settings row already exists (may have been auto-created). Note: join via organization_id — confirm the correct join key against premium_churches or churches:

    SELECT id, organization_id, chatbot_config, agent_config, widget_primary_color, widget_position
    FROM organization_settings
    WHERE organization_id = '[organization_uuid]';
  4. If no row exists, INSERT one with chatbot config inside the chatbot_config JSONB column:

    INSERT INTO organization_settings (
    organization_id,
    chatbot_config,
    widget_primary_color,
    widget_position,
    updated_at
    ) VALUES (
    '[organization_uuid]',
    jsonb_build_object(
    'welcome_message', jsonb_build_object(
    'text', 'Hi! I''m here to help with questions about our church. How can I assist you?',
    'cta_buttons', '[]'::jsonb,
    'greeting_variants', '[]'::jsonb
    ),
    'behavior', jsonb_build_object(
    'tone', 'friendly',
    'language', 'en',
    'response_length', 'medium',
    'theological_lens', '[lens_name]' -- e.g. 'ecumenical', 'reformed', etc.
    ),
    'appearance', jsonb_build_object(
    'logo_url', null,
    'position', 'bottom-right',
    'custom_css', null,
    'primary_color', '#4F46E5'
    ),
    'knowledge_base', jsonb_build_object(
    'max_documents', 100,
    'scraping_enabled', false,
    'faq_management_enabled', true
    )
    ),
    '#1B365D',
    'bottom-right',
    now()
    );
  5. If a row exists and chatbot needs enabling, update the chatbot_config JSONB:

    UPDATE organization_settings
    SET chatbot_config = chatbot_config || '{"enabled": true}'::jsonb,
    updated_at = now()
    WHERE organization_id = '[organization_uuid]';
  6. For Pro Website churches — chatbot is automatically provisioned on signup with a simplified toolset (Q&A + prayer requests only, no RAG). There is no pro_website_mode column in organization_settings. Pro Website mode restrictions are enforced at the application layer (not the DB schema). Verify the church's chatbot config:

    SELECT organization_id, chatbot_config, agent_config, agent_tool_config
    FROM organization_settings
    WHERE organization_id = '[organization_uuid]';
  7. Provide the church admin with their embed code. Direct them to the admin dashboard:

    https://churchwiseai.com/admin/[token]/settings

    The embed code is available there. It includes the church-specific widget script tag.

  8. Test the chatbot via the admin dashboard preview or by embedding the widget on a test page:

    • Ask a general question about the church
    • Submit a prayer request
    • Verify the response style matches the theological lens

Verification

  • organization_settings row exists for the church's organization_id.
  • chatbot_config JSONB contains a valid welcome_message and behavior block.
  • Chatbot responds correctly at the admin preview URL.
  • Prayer requests submitted via chatbot appear in voice_prayer_requests.

Rollback

To disable the chatbot (via application-layer flag in the JSONB config):

UPDATE organization_settings
SET chatbot_config = chatbot_config || '{"enabled": false}'::jsonb,
updated_at = now()
WHERE organization_id = '[organization_uuid]';

Note: confirm with the chatbot route code (churchwiseai-web/src/app/api/chatbot/stream/route.ts) which field it reads for the enabled/disabled state — it may use premium_churches.status rather than anything in organization_settings.

See Also