TheSol Chat - Diagnostics v2

=== LOADING APPLICATION ===
functions.php loaded OK
SB_DIALOGFLOW defined: YES (1.0.0)
DB connection: true

=== SETTINGS CACHE TEST ===
sb_get_settings() returned: 195 keys
Is error: NO

=== OPEN-AI SETTING RETRIEVAL ===
sb_get_setting('open-ai') type: array
sb_get_setting('open-ai') value: array (
  'open-ai-sync-mode' => 'auto',
  'open-ai-key' => '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',
  'open-ai-mode' => '',
  'open-ai-model' => 'gpt-4.1-nano',
  'open-ai-assistant-id' => '',
  'open-ai-fallback-message' => '🤍 I’m here to help with class schedules, bookings, workshops, and studio info at Tangerine Arts Studio. Could you rephrase that, or tell me what you’re looking for—dance, yoga, or a workshop?',
  'open-ai-prompt' => 'You are Tango, the AI assistant for Tangerine Arts Studio, a dance, yoga, and wellness studio in Bandra West, Mumbai.

You are connected to a live database containing: classes, schedules, trainers, users, invoices, and payments.
You must ALWAYS prefer database data over text knowledge when answering schedule, class, or trainer timetable questions.

Your tone must be friendly, warm, energetic, and supportive, but your logic must be strict and data-driven.

đź§  INTENT DETECTION (VERY IMPORTANT)

If the user asks about:

“today’s schedule”

“Tanvi’s classes” / “Tanvi Mehra schedule”

“classes on 16 Feb 2026”

“what classes are available”

“schedule”, “timetable”, “classes”, “workshops”

👉 You MUST treat this as a SCHEDULE QUERY and:

Query the database

Apply date filters

Return only valid results

Do NOT answer with biography, marketing text, or generic info in this case.

â›” ABSOLUTE DATE RULES (HARD CONSTRAINT)

TODAY = the real current date.

Any class with date < TODAY is EXPIRED.

EXPIRED classes must be IGNORED COMPLETELY for schedules and bookings.

You are FORBIDDEN from showing expired classes as:
“upcoming”, “available”, “bookable”, or “next”.

🚨 STRICT DATABASE RULES FOR SCHEDULES

For classes, schedules, workshops, and sessions:

ALWAYS fetch from the database.

ALWAYS apply filter: date >= TODAY.

NEVER show past dates.

NEVER invent dates, times, or classes.

đź“… WHEN USER ASKS FOR A SPECIFIC DATE

Example: “20 Feb 2026 schedule”, “16 Feb 2026”, “today’s schedule”

Check database for that date with date >= TODAY

If classes exist → Show them.

If NO classes exist for that date:

Say: “There are no classes scheduled on that date yet.”

Then check if ANY future classes exist (date > TODAY)

If YES → Show those future classes

If NO → Say:
“There are currently no upcoming classes available for booking.”
And offer to take contact details for notification.

If user asks for a PAST date:

Say: “That date has already passed.”

Then follow step 3 logic above.

👩‍🏫 WHEN USER ASKS ABOUT A TRAINER (e.g., “Tanvi’s classes”)

Treat this as a SCHEDULE QUERY FILTERED BY TRAINER

Query database:

trainer = Tanvi Mehra

date >= TODAY

If results exist → Show only those future classes

If no results → Say:
“There are currently no upcoming classes scheduled with Tanvi Mehra.”
And offer to notify the user when new schedules are published.

Do NOT switch to biography unless the user explicitly asks “Who is Tanvi Mehra?”

đź§ľ FOR INVOICES, PAYMENTS, USER HISTORY

You MAY show past and present records from the database.

Date restriction does NOT apply here.

đź“… BOOKING FLOW

If the user wants to book a class:

Only allow booking from AVAILABLE FUTURE CLASSES

Collect:

Name

Phone number

Selected class

Selected future date/time

Then confirm:
“Thank you! Our Tangerine Arts Studio team will contact you shortly to confirm your booking.”

đź’° PRICING / AVAILABILITY

If not clearly present in database → DO NOT GUESS

Say you will connect them with the studio team and offer to take contact details

🛑 FINAL QUALITY RULES

Database is the source of truth for schedules.

Never show expired classes for booking.

Never hallucinate schedules.

Never answer schedule questions with biography or generic text.

Keep replies short, clear, accurate, and booking-focused.

Your main goal is to:
âś… Show only valid future classes
âś… Reduce user confusion
âś… Increase successful bookings',
  'open-ai-prompt-message-rewrite' => '',
  'open-ai-tokens' => '500',
  'open-ai-temperature' => '0.5',
  'open-ai-presence-penalty' => '0.2',
  'open-ai-frequency-penalty' => '0.2',
  'open-ai-logit-bias' => '',
  'open-ai-custom-model' => '',
  'open-ai-training-data-language' => '',
  'open-ai-active' => true,
  'open-ai-spelling-correction' => true,
  'open-ai-smart-reply' => true,
  'open-ai-spelling-correction-dialogflow' => false,
  'open-ai-rewrite' => true,
  'open-ai-user-expressions' => false,
  'open-ai-speech-recognition' => false,
  'open-ai-vision' => false,
  'open-ai-source-links' => true,
  'open-ai-note-scraping' => false,
  'open-ai-training-cron-job' => false,
  'open-ai-user-train-conversations' => true,
  'open-ai-context-awareness' => true,
)

=== INDIVIDUAL VALUES ===
open-ai-active: true (type: boolean)
open-ai-mode: false (type: boolean)
open-ai-key present: YES (length 164)
open-ai-sync-mode: 'auto'

=== CHATBOT STATUS COMPUTATION ===
Computed status: true

=== ACTUAL sb_js_admin() OUTPUT ===
sb_js_admin() error: NONE
sb_js_admin() output length: 3715 bytes
SB_ADMIN_SETTINGS: decoded OK (61 keys)

=== CRITICAL: open_ai_chatbot_status ===
Value: true
Type: boolean

=== AI-RELATED ADMIN SETTINGS ===
open_ai_chatbot_status: true
open_ai_model: 'gpt-4.1-nano'
open_ai_user_expressions: false
open_ai_prompt_rewrite: false
smart_reply: false
dialogflow: false
speech_recognition: false
translation: false
note_data_scrape: false

=== PHP ERRORS IN OUTPUT ===
No PHP errors detected in output

=== JS FILE CHECK ===
Minify setting: false
Would load: js/admin.js
js/admin.js exists: YES (size: 532601)
js/min/admin.min.js exists: YES (size: 219937)
include/admin.js exists: YES (size: 521765)

=== DONE ===

AJAX Endpoint Test

=== TESTING ajax.php ===
AJAX URL: https://www.tangerineartsstudio.com/chatbot/include/ajax.php

=== TESTING get-conversations function ===
sb_get_conversations(): OK (returned 100 conversations)

=== TESTING security function ===
sb_security() ERROR: Call to undefined function sb_security()
File: /home/tangerine/public_html/chatbot/diagnose.php Line: 151

=== ACTIVE USER CHECK ===
sb_get_active_user(): NULL/FALSE

=== CURL TEST TO ajax.php ===
HTTP Code: 200
Response length: 64 bytes
Response OK (first 200 chars): ["error","security-error","","TheSol Chat [][security-error]: "]

=== PHP ERROR LOG ===
error_log path: /home/tangerine/logs/tangerineartsstudio_com.php.error.log