Skip to content

Storage Keys

Browser Storage

localStorage

KeyTypeDescription
chat-panel-sizestringChat widget panel size preference ('default' or 'expanded')

sessionStorage

KeyTypeDescription
chat-messagesJSONCached chat messages for session continuity
chat-sessionJSONSession state ({ state, mode }) for reconnection

Both keys are cleared when a session ends.

Cloudflare KV (THREAD_MAP)

Key PatternValueTTLDescription
rate:session:{ip}Count (string)3600sRate limit counter per IP
{threadTs}Session ID (string)1800sMaps Slack thread to DO session
block:ip:{ip}AnyNoneIP block list entry
block:email:{email}AnyNoneEmail block list entry

Durable Object Storage

Stored within each ChatSession Durable Object instance:

KeyTypeDescription
session_stateSessionStateCore session data (visitor info, mode, Slack thread)
last_visitor_messagenumberTimestamp of last visitor message (inactivity tracking)
last_anshul_replynumberTimestamp of last Anshul reply (away indicator)
last_unmatched_textstringLast bot question — forwarded to Slack on escalation
session_idstringSession UUID
conversation_historyConversationHistoryAI chat history (messages + summary)
message_countnumberTotal messages sent in the session

SessionState Shape

typescript
interface SessionState {
  visitorName: string;
  visitorEmail: string;
  startPage: string;
  slackThreadTs: string;
  slackChannelId: string;
  lastActivity: number;
  mode: 'bot' | 'live';
  messageCount?: number;
}

ConversationHistory Shape

typescript
interface ConversationHistory {
  messages: ChatCompletionMessage[];  // Recent messages (sliding window)
  summary: string;                    // Summary of older messages
  messageCount: number;               // Total message count
}

Cookies

NameTypeDomainExpiryDescription
__bypassHttpOnlychat.anshulbisen.com30 daysRate limit bypass for site owner