scripts: setup Freescout custom fields

This commit is contained in:
2026-03-16 16:25:31 +01:00
parent b335ce6254
commit ed8241d1ed
2 changed files with 90 additions and 1 deletions

5
.env
View File

@@ -19,3 +19,8 @@ POSTGRES_PASSWORD=change_me_securely
# Milvus Configuration
MILVUS_API_URL=http://milvus:19530
# Freescout API Configuration
FREESCOUT_API_KEY=your_api_key_here
FREESCOUT_API_BASE=https://ekshelpdesk.fft-it.de/api/v1
FREESCOUT_MAILBOX_ID=1

View File

@@ -0,0 +1,84 @@
#!/bin/bash
# Freescout Custom Fields Setup Script
# Creates 3 custom fields via Freescout API:
# 1. AI_SUGGESTION (Text Field)
# 2. AI_SUGGESTION_STATUS (Dropdown)
# 3. PROCESSED_BY_AI (Checkbox)
set -e
# Environment variables validation
if [ -z "$FREESCOUT_API_BASE" ]; then
echo "❌ Error: FREESCOUT_API_BASE environment variable not set"
exit 1
fi
if [ -z "$FREESCOUT_API_KEY" ]; then
echo "❌ Error: FREESCOUT_API_KEY environment variable not set"
exit 1
fi
if [ -z "$FREESCOUT_MAILBOX_ID" ]; then
echo "❌ Error: FREESCOUT_MAILBOX_ID environment variable not set"
exit 1
fi
echo "Starting Freescout custom fields setup..."
echo "API Base: $FREESCOUT_API_BASE"
echo "Mailbox ID: $FREESCOUT_MAILBOX_ID"
echo ""
# Function to create custom field
create_field() {
local name=$1
local title=$2
local type=$3
local required=$4
local options=$5
echo "Creating field: $name ($title)..."
if [ -z "$options" ]; then
# For text and checkbox fields without options
curl -X POST "$FREESCOUT_API_BASE/mailboxes/$FREESCOUT_MAILBOX_ID/custom-fields" \
-H "Authorization: Bearer $FREESCOUT_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"name\": \"$name\",
\"title\": \"$title\",
\"type\": \"$type\",
\"required\": $required
}" \
-w "\nHTTP Status: %{http_code}\n" \
-s
else
# For select fields with options
curl -X POST "$FREESCOUT_API_BASE/mailboxes/$FREESCOUT_MAILBOX_ID/custom-fields" \
-H "Authorization: Bearer $FREESCOUT_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"name\": \"$name\",
\"title\": \"$title\",
\"type\": \"$type\",
\"required\": $required,
\"options\": $options
}" \
-w "\nHTTP Status: %{http_code}\n" \
-s
fi
echo "✅ Field created: $name"
echo ""
}
# Create Field 1: AI_SUGGESTION (Text Field)
create_field "AI_SUGGESTION" "KI-Vorschlag" "text" "false"
# Create Field 2: AI_SUGGESTION_STATUS (Dropdown/Select)
create_field "AI_SUGGESTION_STATUS" "KI-Status" "select" "false" '["PENDING", "APPROVED", "REJECTED", "EXECUTED"]'
# Create Field 3: PROCESSED_BY_AI (Checkbox)
create_field "PROCESSED_BY_AI" "Von KI verarbeitet" "checkbox" "false"
echo "✅ All Freescout custom fields created successfully!"