Skip to content

KI-Chatbot

Die Chatbot-Funktion ermöglicht Ihnen die Erstellung KI-gestützter Astrologie-Assistenten, die in Ihre Website eingebettet oder über die API verwendet werden können. Chatbots können Fragen zu Geburtshoroskopen und Transiten beantworten und personalisierte astrologische Einblicke liefern.

Übersicht

  • KI-gestützt: Verwendet fortschrittliche Sprachmodelle für natürliche Gespräche
  • Geburtsdaten-bewusst: Chatbots können auf Benutzer-Geburtsdaten für personalisierte Deutungen zugreifen
  • Einbettbares Widget: Einfach einzubauendes Chat-Widget für Ihre Website
  • Streaming-Antworten: Echtzeit-SSE-Streaming für sofortiges Feedback
  • Plugin-System: Spezifische Astrologie-Funktionen pro Chatbot aktivieren
  • Nutzungsverfolgung: Token-Verbrauch und Nachrichtenanzahl überwachen

Einen Chatbot erstellen

bash
curl -X POST "https://api.astroapi.cloud/api/chatbots" \
  -H "X-Api-Key: your-api-key" \
  -H "Content-Type: application/vnd.api+json" \
  -d '{
    "data": {
      "type": "chatbots",
      "attributes": {
        "name": "My Astrology Bot",
        "description": "Personal astrology assistant",
        "enabledPlugins": ["natal", "transits"],
        "settings": {
          "greeting": "Hello! I can help you understand your birth chart."
        },
        "widgetConfig": {
          "theme": "light",
          "primaryColor": "#6366f1"
        },
        "allowedDomains": ["example.com", "www.example.com"]
      }
    }
  }'

Antwort

json
{
  "data": {
    "type": "chatbot",
    "id": "cb_abc123",
    "attributes": {
      "name": "My Astrology Bot",
      "description": "Personal astrology assistant",
      "enabledPlugins": ["natal", "transits"],
      "settings": {
        "greeting": "Hello! I can help you understand your birth chart."
      },
      "widgetConfig": {
        "theme": "light",
        "primaryColor": "#6366f1"
      },
      "allowedDomains": ["example.com", "www.example.com"],
      "createdAt": "2024-01-15T10:30:00Z",
      "updatedAt": "2024-01-15T10:30:00Z"
    }
  }
}

Chat-Endpunkte

Einfacher Chat

Eine Nachricht ohne Geburtsdaten-Kontext senden:

bash
curl -X POST "https://api.astroapi.cloud/api/chat/{chatbotId}" \
  -H "X-Api-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "What does it mean to have Sun in Aries?",
    "conversationId": null
  }'

Chat mit Geburtsdaten

Eine Nachricht mit direkt eingebetteten Geburtsdaten für personalisierte Antworten senden:

bash
curl -X POST "https://api.astroapi.cloud/api/chat/{chatbotId}/direct" \
  -H "X-Api-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Tell me about my Sun sign",
    "birthData": {
      "date": "1990-06-15",
      "time": "14:30",
      "latitude": 51.5074,
      "longitude": -0.1278,
      "placeName": "London, UK",
      "timezone": "Europe/London"
    }
  }'

Chat mit Profil

Ein gespeichertes Profil für konsistente Geburtsdaten über Gespräche hinweg verwenden:

bash
curl -X POST "https://api.astroapi.cloud/api/chat/{chatbotId}/profile/{profileId}" \
  -H "X-Api-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "What transits are affecting me this week?",
    "conversationId": "conv_xyz789"
  }'

Streaming-Antwort

Alle Chat-Endpunkte geben Server-Sent Events (SSE) für Echtzeit-Streaming zurück:

event: message
data: {"content": "Based on your birth chart, "}

event: message
data: {"content": "your Sun in Aries suggests..."}

event: done
data: {"conversationId": "conv_xyz789", "usage": {"inputTokens": 150, "outputTokens": 75}}

Chat-Profile

Profile speichern Geburtsdaten für Benutzer und ermöglichen personalisierte Antworten, ohne die Geburtsdaten jedes Mal erneut zu senden.

Ein Profil erstellen

bash
curl -X POST "https://api.astroapi.cloud/api/chatbots/{chatbotId}/profiles" \
  -H "X-Api-Key: your-api-key" \
  -H "Content-Type: application/vnd.api+json" \
  -d '{
    "data": {
      "type": "chat-profile",
      "attributes": {
        "externalUserId": "user_123",
        "birthDate": "1990-06-15",
        "birthTime": "14:30",
        "birthPlaceLat": 51.5074,
        "birthPlaceLng": -0.1278,
        "birthPlaceName": "London, UK",
        "timezone": "Europe/London",
        "metadata": {
          "name": "John Doe"
        }
      }
    }
  }'

Profile auflisten

bash
curl -X GET "https://api.astroapi.cloud/api/chatbots/{chatbotId}/profiles" \
  -H "X-Api-Key: your-api-key"

Widget-Integration

Betten Sie ein Chat-Widget in Ihre Website ein, indem Sie die Widget-Endpunkte verwenden.

INFO

Widget-Endpunkte verwenden den /widget/-Pfad (ohne /api/-Präfix) und validieren den Origin-Header für Domain-Beschränkungen.

Widget-Konfiguration abrufen

bash
curl -X GET "https://api.astroapi.cloud/widget/config/{chatbotId}"

Widget-Chat

Das Widget verwendet Domain-Validierung über den Origin-Header (vom Browser erzwungen):

bash
curl -X POST "https://api.astroapi.cloud/widget/chat/{chatbotId}" \
  -H "X-Api-Key: your-widget-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "What is my horoscope for today?",
    "birthData": {
      "date": "1990-06-15",
      "time": "14:30",
      "latitude": 51.5074,
      "longitude": -0.1278,
      "timezone": "Europe/London"
    }
  }'

Widget mit Benutzerprofilen

Für wiederkehrende Benutzer den externen Benutzer-ID-Endpunkt verwenden. Das Profil wird beim ersten Zugriff automatisch erstellt:

bash
curl -X POST "https://api.astroapi.cloud/widget/chat/{chatbotId}/user/{externalUserId}" \
  -H "X-Api-Key: your-widget-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "What are my current transits?",
    "birthData": {
      "date": "1990-06-15",
      "time": "14:30",
      "latitude": 51.5074,
      "longitude": -0.1278,
      "timezone": "Europe/London"
    }
  }'

TIP

Geburtsdaten sind nur bei der ersten Nachricht für einen neuen Benutzer erforderlich. Nachfolgende Nachrichten können diese weglassen.

Domain-Beschränkungen

Aus Sicherheitsgründen können Sie festlegen, welche Domains auf Ihr Widget zugreifen dürfen:

json
{
  "allowedDomains": ["example.com", "www.example.com", "app.example.com"]
}

Wenn allowedDomains leer ist, sind alle Domains erlaubt.

Verfügbare Plugins

Plugins bestimmen, auf welche astrologischen Funktionen der Chatbot zugreifen kann:

PluginBeschreibungErforderliches Modul
natalGeburtshoroskop-Berechnungen und Interpretationenmodule:natal
transitAktuelle Transit-Informationenmodule:transit
synastryBeziehungskompatibilitätsanalysemodule:synastry
compositeKomposit-Horoskop-Analysemodule:composite
progressionsSekundäre Progressionenmodule:progression
solar_returnSonnenrückkehr-Horoskopemodule:solar-return
lunar_returnMondrückkehr-Horoskopemodule:lunar-return
retrogradeInformationen zu rückläufigen Periodenmodule:retrograde
numerologyNumerologie-Berechnungenmodule:numerology
compatibilityAstrologische Kompatibilitätmodule:compatibility
chinese_zodiacChinesische Tierkreisinformationenmodule:chinese-horoscope
daily_insightTägliche astrologische Einblickemodule:transit
moonMondphasen- und Kalenderdatenmodule:moon
daily_horoscopeTageshoroskop-Inhaltemodule:daily-report

TIP

Verwenden Sie GET /api/chatbots/plugins, um alle verfügbaren Plugins aufzulisten, oder GET /api/chatbots/available-plugins, um zu sehen, welche Plugins basierend auf den Modulen Ihrer Organisation verfügbar sind.

Gesprächsverlauf

Gespräch abrufen

Den vollständigen Nachrichtenverlauf abrufen:

bash
curl -X GET "https://api.astroapi.cloud/api/chat/{chatbotId}/conversation/{conversationId}" \
  -H "X-Api-Key: your-api-key"

Gespräch löschen

bash
curl -X DELETE "https://api.astroapi.cloud/api/chat/{chatbotId}/conversation/{conversationId}" \
  -H "X-Api-Key: your-api-key"

Nutzungsverfolgung

Ihre Chatbot-Nutzung überwachen:

bash
curl -X GET "https://api.astroapi.cloud/api/chatbots/usage" \
  -H "X-Api-Key: your-api-key"

Antwort

json
{
  "data": {
    "type": "chatbot-usage",
    "id": "org_abc-2024-01",
    "attributes": {
      "month": "2024-01",
      "totalInputTokens": 15000,
      "totalOutputTokens": 45000,
      "totalMessages": 250
    }
  }
}

Chatbots verwalten

Chatbots auflisten

bash
curl -X GET "https://api.astroapi.cloud/api/chatbots" \
  -H "X-Api-Key: your-api-key"

Chatbot aktualisieren

bash
curl -X PATCH "https://api.astroapi.cloud/api/chatbots/{id}" \
  -H "X-Api-Key: your-api-key" \
  -H "Content-Type: application/vnd.api+json" \
  -d '{
    "data": {
      "type": "chatbots",
      "attributes": {
        "name": "Updated Bot Name",
        "enabledPlugins": ["natal", "transits", "synastry"]
      }
    }
  }'

Chatbot löschen

bash
curl -X DELETE "https://api.astroapi.cloud/api/chatbots/{id}" \
  -H "X-Api-Key: your-api-key"

Fehlerbehandlung

Häufige Fehlerantworten:

StatusBeschreibung
400Ungültige Anfrage (fehlende Felder, Validierungsfehler)
401API-Schlüssel erforderlich oder ungültig
403Domain nicht erlaubt (Widget) oder keine aktive Organisation
404Chatbot, Profil oder Gespräch nicht gefunden

Beispiel-Fehlerantwort:

json
{
  "errors": [{
    "status": "403",
    "title": "Domain not allowed"
  }]
}

AstroAPI Documentation