Skip to main content
POST
/
api
/
save-settings.php
Save Settings
curl --request POST \
  --url https://api.example.com/api/save-settings.php \
  --header 'Content-Type: application/json' \
  --data '
{
  "systemPrompt": "<string>",
  "welcomeMessage": "<string>",
  "errorMessage": "<string>",
  "contextMessagesCount": 123,
  "calendarEnabled": true,
  "botMode": "<string>",
  "botName": "<string>"
}
'
{
  "success": true,
  "message": "<string>",
  "error": "<string>"
}

Overview

Updates general bot settings. All fields are optional - only provided fields will be updated.

Request

systemPrompt
string
AI system prompt that defines the bot’s personality and behavior
welcomeMessage
string
Initial greeting message sent to new users
errorMessage
string
Fallback message when the bot cannot find relevant information
contextMessagesCount
integer
Number of previous messages to include in conversation context (affects AI memory)
calendarEnabled
boolean
Enable or disable Google Calendar integration
botMode
string
Operating mode: "ai" for RAG-powered responses or "classic" for flow-based conversations
botName
string
Display name for the bot
curl -X POST https://your-domain.com/api/save-settings.php \
  -H "Content-Type: application/json" \
  -d '{
    "systemPrompt": "You are a helpful customer service assistant.",
    "welcomeMessage": "Hello! How can I help you today?",
    "contextMessagesCount": 10,
    "botMode": "ai"
  }'

Response

success
boolean
required
Indicates if the settings were saved successfully
message
string
Confirmation message (only present on success)
error
string
Error description (only present on failure)

Success Response Example

{
  "success": true,
  "message": "Configuración guardada correctamente"
}

Error Response Examples

{
  "success": false,
  "error": "Error al guardar configuración"
}
{
  "success": false,
  "error": "Invalid JSON input"
}

Error Handling

Status CodeDescription
200Settings saved successfully
405Method not allowed (only POST accepted)
500Internal server error

Implementation Details

The endpoint:
  1. Validates that the request method is POST
  2. Parses the JSON request body
  3. Maps JSON keys to database setting keys
  4. Uses INSERT … ON DUPLICATE KEY UPDATE to upsert settings
  5. Converts boolean values to string representation for storage
  6. Logs the operation for audit purposes
Source: api/save-settings.php:19-42

Notes

  • All parameters are optional - send only the fields you want to update
  • Boolean values are automatically converted to strings ("true" or "false")
  • Settings are stored individually in the database for flexibility
  • Changes take effect immediately for new conversations

Build docs developers (and LLMs) love