CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  username VARCHAR(50),
  password VARCHAR(255),
  role ENUM('admin','operator') DEFAULT 'operator'
);

CREATE TABLE sessions (
  id INT AUTO_INCREMENT PRIMARY KEY,
  session_id VARCHAR(50) UNIQUE,
  name VARCHAR(100),
  status ENUM('disconnected','connected') DEFAULT 'disconnected',
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE messages (
  id INT AUTO_INCREMENT PRIMARY KEY,
  session_id VARCHAR(50),
  sender VARCHAR(50),
  message TEXT,
  direction ENUM('in','out'),
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE chatbots (
  id INT AUTO_INCREMENT PRIMARY KEY,
  session_id VARCHAR(50),
  keyword VARCHAR(100),
  response TEXT
);

CREATE TABLE webhooks (
  id INT AUTO_INCREMENT PRIMARY KEY,
  session_id VARCHAR(50),
  url TEXT
);
