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
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
{
"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:
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:
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:
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
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
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
curl -X GET "https://api.astroapi.cloud/widget/config/{chatbotId}"Widget-chat
De widget gebruikt domeinvalidatie via de Origin-header (afgedwongen door de browser):
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:
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:
{
"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:
| Plugin | Beschrijving | Vereiste module |
|---|---|---|
natal | Geboortehoroscoopberekeningen en interpretaties | module:natal |
transit | Actuele transitinformatie | module:transit |
synastry | Relatiecompatibiliteitsanalyse | module:synastry |
composite | Composiethoroscoopanalyse | module:composite |
progressions | Secundaire progressies | module:progression |
solar_return | Zonneretourhoroscopen | module:solar-return |
lunar_return | Maanretourhoroscopen | module:lunar-return |
retrograde | Retrograde-periode-informatie | module:retrograde |
numerology | Numerologieberekeningen | module:numerology |
compatibility | Astrologische compatibiliteit | module:compatibility |
chinese_zodiac | Chinese dierenrieminformatie | module:chinese-horoscope |
daily_insight | Dagelijkse astrologische inzichten | module:transit |
moon | Maanfase- en kalendergegevens | module:moon |
daily_horoscope | Dagelijkse horoscoopcontent | module: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:
curl -X GET "https://api.astroapi.cloud/api/chat/{chatbotId}/conversation/{conversationId}" \
-H "X-Api-Key: your-api-key"Gesprek verwijderen
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:
curl -X GET "https://api.astroapi.cloud/api/chatbots/usage" \
-H "X-Api-Key: your-api-key"Response
{
"data": {
"type": "chatbot-usage",
"id": "org_abc-2024-01",
"attributes": {
"month": "2024-01",
"totalInputTokens": 15000,
"totalOutputTokens": 45000,
"totalMessages": 250
}
}
}Chatbots beheren
Chatbots opvragen
curl -X GET "https://api.astroapi.cloud/api/chatbots" \
-H "X-Api-Key: your-api-key"Chatbot bijwerken
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
curl -X DELETE "https://api.astroapi.cloud/api/chatbots/{id}" \
-H "X-Api-Key: your-api-key"Foutafhandeling
Veelvoorkomende foutresponses:
| Status | Beschrijving |
|---|---|
| 400 | Ongeldig verzoek (ontbrekende velden, validatiefouten) |
| 401 | API key vereist of ongeldig |
| 403 | Domein niet toegestaan (widget) of geen actieve organisatie |
| 404 | Chatbot, profiel of gesprek niet gevonden |
Voorbeeld foutresponse:
{
"errors": [{
"status": "403",
"title": "Domain not allowed"
}]
}