Skip to content

AI Chatbot

De Chatbot-functie stelt u in staat AI-gestuurde astrologie-assistenten te maken die in uw website kunnen worden ingebed of via de API kunnen worden gebruikt. Chatbots kunnen vragen beantwoorden over geboortehoroscopen, transits en gepersonaliseerde astrologische inzichten bieden.

Overzicht

  • AI-gestuurd: Gebruikt geavanceerde taalmodellen voor natuurlijke conversatie
  • Geboortegegevens-bewust: Chatbots hebben toegang tot geboortegegevens van gebruikers voor gepersonaliseerde duidingen
  • Insluitbare widget: Drop-in chatwidget voor uw website
  • Streaming responses: Realtime SSE-streaming voor directe feedback
  • Pluginsysteem: Schakel specifieke astrologiefuncties per chatbot in
  • Gebruikstracering: Monitor tokengebruik en berichtaantallen

Een chatbot aanmaken

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"]
      }
    }
  }'

Response

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-endpoints

Basischat

Stuur een bericht zonder geboortegegevenscontext:

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 met geboortegegevens

Stuur een bericht met inline geboortegegevens voor gepersonaliseerde antwoorden:

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 met profiel

Gebruik een opgeslagen profiel voor consistente geboortegegevens over gesprekken heen:

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 response

Alle chat-endpoints retourneren Server-Sent Events (SSE) voor realtime streaming:

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}}

Chatprofielen

Profielen slaan geboortegegevens op voor gebruikers, waardoor gepersonaliseerde antwoorden mogelijk zijn zonder de geboortegegevens telkens opnieuw te versturen.

Een profiel aanmaken

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"
        }
      }
    }
  }'

Profielen opvragen

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

Widget-integratie

Sluit een chatwidget in op uw website met de widget-endpoints.

INFO

Widget-endpoints gebruiken het /widget/-pad (zonder /api/-prefix) en valideren de Origin-header voor domeinbeperkingen.

Widgetconfiguratie ophalen

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

Widget-chat

De widget gebruikt domeinvalidatie via de Origin-header (afgedwongen door de browser):

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 met gebruikersprofielen

Voor terugkerende gebruikers kunt u het externe gebruikers-ID endpoint gebruiken. Het profiel wordt automatisch aangemaakt bij het eerste gebruik:

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

Geboortegegevens zijn alleen vereist bij het eerste bericht voor een nieuwe gebruiker. Volgende berichten kunnen deze weglaten.

Domeinbeperkingen

Voor de veiligheid kunt u beperken welke domeinen toegang hebben tot uw widget:

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

Als allowedDomains leeg is, zijn alle domeinen toegestaan.

Beschikbare plugins

Plugins bepalen tot welke astrologische functies de chatbot toegang heeft:

PluginBeschrijvingVereiste module
natalGeboortehoroscoopberekeningen en interpretatiesmodule:natal
transitActuele transitinformatiemodule:transit
synastryRelatiecompatibiliteitsanalysemodule:synastry
compositeComposiethoroscoopanalysemodule:composite
progressionsSecundaire progressiesmodule:progression
solar_returnZonneretourhoroscopenmodule:solar-return
lunar_returnMaanretourhoroscopenmodule:lunar-return
retrogradeRetrograde-periode-informatiemodule:retrograde
numerologyNumerologieberekeningenmodule:numerology
compatibilityAstrologische compatibiliteitmodule:compatibility
chinese_zodiacChinese dierenrieminformatiemodule:chinese-horoscope
daily_insightDagelijkse astrologische inzichtenmodule:transit
moonMaanfase- en kalendergegevensmodule:moon
daily_horoscopeDagelijkse horoscoopcontentmodule:daily-report

TIP

Gebruik GET /api/chatbots/plugins om alle beschikbare plugins op te vragen, of GET /api/chatbots/available-plugins om te zien welke plugins beschikbaar zijn op basis van de modules van uw organisatie.

Gespreksgeschiedenis

Gesprek ophalen

Haal de volledige berichtengeschiedenis op:

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

Gesprek verwijderen

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

Gebruikstracering

Monitor het gebruik van uw chatbot:

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

Response

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

Chatbots beheren

Chatbots opvragen

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

Chatbot bijwerken

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 verwijderen

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

Foutafhandeling

Veelvoorkomende foutresponses:

StatusBeschrijving
400Ongeldig verzoek (ontbrekende velden, validatiefouten)
401API key vereist of ongeldig
403Domein niet toegestaan (widget) of geen actieve organisatie
404Chatbot, profiel of gesprek niet gevonden

Voorbeeld foutresponse:

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

AstroAPI Documentation