Home
Cart


Soarenity Blue API Documentation

Integrate Soarenity's automation, AI, and avatar into your app or site in minutes.
Questions? support@soarenity.ai

Quick Start

  1. Subscribe to Soarenity and generate your API key.
    Your API key is required for all requests. Every API call must set your key in the X-API-Key header.
  2. Download the Soarenity Blue integration files from your dashboard.
    You will receive blue_action_listener.js (template), blue_knowledge.py, blue_app.py, gpt_service.py, elevenlabs_service.py, and blue_memory.py.
  3. Add files to your project: - Place Python files in your backend.
    - Place blue_action_listener.js in your frontend/scripts directory.
    - Only blue_action_listener.js should be customized for your UI/flow; all other files are drop-in ready.
  4. Set up a /soarenity_action endpoint in your backend.
    This endpoint must accept POSTs from blue_action_listener.js and handle actions triggered by Blue.
    Request Example:
    JSON Request Example
    {"action":"some_action","parameters":{ }}
    Response Example:
    JSON Response Example
    {"status":"success"}
    Document your accepted actions for your users.
  5. Configure your account and knowledgebase:
    In your dashboard (Profile → API Dashboard), add actions, upload knowledgebase topics, and choose your voice. All customizations flow into Blue's context.

Endpoints

POST /api/blue_v1

Main endpoint for all automations, questions, and avatar interactions.

Request:
HTTP Request
POST /api/blue_v1 Headers: X-API-Key: YOUR_API_KEY Body: { "text": "Show me my orders", "device_id": "USER_DEVICE_OR_SESSION_ID" }

device_id can be any string unique to the user/session/device. All state (memory, context) is scoped to this value.

Returns: JSON with these fields:

JSON Response
{ "response": "Here are your recent orders...", "audio_url": "/static/audio/blue_tts_xxxx.mp3", "avatar_state": "talking", "next_action": { "method": "GET", "endpoint": "/user/orders", "params": {} }, "pending_action": { "action": "refund_order", "parameters": { } } }

- If pending_action is present, send the user's followup message and this entire object back in your next request to continue.
- If next_action is present, trigger automation via your own backend or via /soarenity_action.

Required: /soarenity_action

This is your backend POST endpoint for Blue to trigger custom actions you have defined in your API Dashboard.
Blue will POST to this endpoint with:

JSON Action Request
{"action": "action_name", "parameters": { }}
and expects a JSON response.
You must return a result (success, error, or data) for each request.

Complete Example Implementation:

Python Flask /soarenity_action Example
@app.route("/soarenity_action", methods=["POST"]) def soarenity_action(): import sys print("\n--- /soarenity_action CALLED ---", file=sys.stderr) try: data = request.get_json(force=True) print("[soarenity_action] Received data:", data, file=sys.stderr) except Exception as ex: print("[soarenity_action] Failed to parse JSON:", ex, file=sys.stderr) return jsonify({"error": "Failed to parse JSON", "detail": str(ex)}), 400 method = (data.get("method") or "GET").upper() endpoint = data.get("endpoint") or "/" # Defensive: Always ensure params is a dict, not None params = data.get("params") if params is None: params = {} print(f"[soarenity_action] method={method} endpoint={endpoint} params={params}", file=sys.stderr) # Defensive: Make sure endpoint is a string if not isinstance(endpoint, str): print("[soarenity_action] ERROR: Endpoint is not a string", file=sys.stderr) return jsonify({"error": "Invalid endpoint"}), 400 # Navigation action: GET with endpoint starting with "/" and NO params (fix: handle both None and empty dict) if method == "GET" and endpoint.startswith("/") and (not params or params == {}): print(f"[soarenity_action] Navigation detected: navigate to {endpoint}", file=sys.stderr) return jsonify({"navigate": endpoint}) # External URL navigation (http/https) if method == "GET" and endpoint.startswith("http"): print(f"[soarenity_action] External navigation detected: navigate to {endpoint}", file=sys.stderr) return jsonify({"navigate": endpoint}) # --- MAIN FIX: Convert local endpoints to full URLs --- if endpoint.startswith("/"): full_endpoint = request.host_url.rstrip("/") + endpoint print(f"[soarenity_action] Converted local endpoint to full URL: {full_endpoint}", file=sys.stderr) endpoint = full_endpoint # Backend HTTP actions (supports GET, POST, PUT, DELETE, PATCH) try: import requests print(f"[soarenity_action] Performing backend HTTP {method} to {endpoint}...", file=sys.stderr) if method == "GET": resp = requests.get(endpoint, params=params, timeout=12) elif method == "POST": resp = requests.post(endpoint, json=params, timeout=12) elif method == "PUT": resp = requests.put(endpoint, json=params, timeout=12) elif method == "DELETE": resp = requests.delete(endpoint, json=params, timeout=12) elif method == "PATCH": resp = requests.patch(endpoint, json=params, timeout=12) else: print(f"[soarenity_action] ERROR: Unsupported method {method}", file=sys.stderr) return jsonify({"error": f"Unsupported method: {method}"}), 400 print(f"[soarenity_action] Response status: {resp.status_code}", file=sys.stderr) try: result = resp.json() print(f"[soarenity_action] JSON result: {result}", file=sys.stderr) return jsonify(result), resp.status_code except Exception as ex: print(f"[soarenity_action] Non-JSON result, sending raw text. Exception: {ex}", file=sys.stderr) return jsonify({"raw_body": resp.text}), resp.status_code except Exception as ex: print(f"[soarenity_action] EXCEPTION in HTTP call: {ex}", file=sys.stderr) return jsonify({"error": str(ex)}), 500

How Clarifications Work

  • If Blue can't determine all needed info, the response will include pending_action and a clarification response.
  • Your UI must present the clarification to the user and POST their answer with the pending_action in the next request.
  • This loop repeats until all parameters are complete, then Blue executes the action automatically.

Avatars & Animation

  • Update the avatar by swapping your image/GIF for the given avatar_state (idle, talking).

Customization & Knowledgebase

  • Actions, Knowledgebase, and Voice are managed in your API Dashboard.
    - You can define up to 40 actions and 25 topics per API key.
    - All knowledge and actions you add flow into Blue's reasoning automatically for every call.
  • API Key is required for all calls. Generate this in the dashboard and include as X-API-Key header.

File & Integration Notes

  • All files except blue_action_listener.js should be treated as drop-in. Only update if you need to add new backend actions or change the frontend UI.
  • Refer to blue_action_listener.js for integration hooks, example event handling, and how to wire up to your UI.

API Call Structure

HTTP Request Example
POST /api/blue_v1 Headers: X-API-Key: YOUR_API_KEY Body: { "text": "How do I track my order?", "device_id": "DEVICE_OR_SESSION_ID" }
- All API calls must use your unique API key in the headers.
- device_id is required on every request.
- Blue may return pending_action if more info is needed.

Audio Response Handling

  • audio_url will point to a generated or pre-recorded MP3 file for the response.
  • Blue will not generate audio for JSON, code, or instructional replies.
  • When a response is a clarification question, audio_url will be included only if appropriate.

Support

For help, API keys, dashboard setup, or advanced use cases, contact our team.

Soarenity Blue Avatar
Soarenity Blue