Retrieve a Chat Agent via API

Markdown

View as Markdown

Retrieve a Chat Agent via API (GET Request)

This article explains how to retrieve a Chat Agent (chatbot) from your Flora AI account using a GET request. You will learn the required endpoint, headers, and see working examples in Python, JavaScript, and cURL.


1. Overview

You can fetch the configuration and details of a specific Chat Agent by sending an authenticated GET request to the Flora AI Chatbot API. This is useful when you need to:

  • Inspect a chatbot’s configuration (model, temperature, initial message, etc.).

  • Integrate chatbot metadata into your own application.

  • Verify that a chatbot exists and is accessible with your API token.


2. API Endpoint

Use the following endpoint to retrieve a specific Chat Agent:

https://app.floraai.me/en/chatbot/api/v1/chatbot/your_chatbot_uuid/

Replace:

  • your_chatbot_uuid with the actual UUID of your chatbot (e.g., a1b2c3d4-5678-90ab-cdef-1234567890ab).

Example:

https://app.floraai.me/en/chatbot/api/v1/chatbot/a1b2c3d4-5678-90ab-cdef-1234567890ab/

3. Required Request Headers

Your request must include the following headers:

Content-Type: application/jsonAuthorization: Token <Your-API-Token>

Where:

  • Content-Type must be application/json.

  • Authorization must be in the format: Token YOUR_API_TOKEN.

If you omit or misconfigure these headers, you may receive authentication or validation errors (e.g., 401 Unauthorized or 403 Forbidden).


4. Example Requests

4.1 Python Example (using requests)

import requests# Define the API endpointurl = "https://app.floraai.me/en/chatbot/api/v1/chatbot/your_chatbot_uuid/"# Set up authentication and headersheaders = {    'Authorization': 'Token <YOUR-API-TOKEN>',    'Content-Type': 'application/json',    'Accept': 'application/json'}# Send the GET requestresponse = requests.get(url, headers=headers)# Process the responseif response.status_code in (200, 201, 202):    result = response.json()    print("Response data:", result)else:    try:        error_data = response.json()        error_message = error_data.get('message') or error_data.get('error', 'Unknown error')        print(f"Error: {error_message}")    except ValueError:        print(f"Error: Status code {response.status_code}")

Key points:

  • Replace your_chatbot_uuid with your chatbot’s UUID.

  • Replace <YOUR-API-TOKEN> with your actual API token.

  • The script checks for success status codes (200, 201, 202) and prints either the data or an error message.


4.2 JavaScript Example (using fetch)

// API endpointconst url = "https://app.floraai.me/en/chatbot/api/v1/chatbot/yourchatbotuuid/";// Request headersconst headers = {  Authorization: "Token YOUR_API_TOKEN",  "Content-Type": "application/json",};// Make the API request using fetchfetch(url, {  method: "GET",  headers,})  .then((response) => {    if ([200, 201, 202].includes(response.status)) {      return response.json();    }    return response.json().then((errorData) => {      const errorMessage =        errorData.message || `Error: Received status code ${response.status}`;      throw new Error(errorMessage);    });  })  .then((data) => {    console.log("Response:", data);  })  .catch((error) => {    console.error("Error:", error.message || "Unknown error occurred.");  });

Key points:

  • Replace yourchatbotuuid with your chatbot’s UUID.

  • Replace YOUR_API_TOKEN with your actual API token.

  • The code handles both successful responses and error responses, logging appropriate messages.


4.3 cURL / Shell Example

# API endpointURL="https://app.floraai.me/en/chatbot/api/v1/chatbot/your_chatbot_uuid/"curl -X GET \  -H "Authorization: Token YOUR_API_TOKEN" \  -H "Content-Type: application/json" \  "${URL}"

Key points:

  • Replace your_chatbot_uuid in URL with your chatbot’s UUID.

  • Replace YOUR_API_TOKEN with your actual API token.

  • The response will be printed to your terminal as JSON.


5. Example Response

A successful request returns a JSON object describing the Chat Agent. Example:

{  "id": 6,  "name": "AI Meeting Scheduler",  "display_name": "AI Meeting Scheduler",  "chatgpt_model_key": "GPT_4_O_2024_05_13",  "temperature": "0.1",  "support_email": "[email protected]",  "base_system_message": "Bass system Prompt.",  "conversation_starter_message": "",  "initial_message": "Hi! What can I help you with?",  "show_data_sources": false,  "persistent_conversation_starter_message": false,  "debug_mode": false,  "audio_io_enabled": false,  "image_upload_enabled": false}

Common fields:

  • id: Internal numeric ID of the chatbot.

  • name: Internal name of the chatbot.

  • display_name: User-facing name of the chatbot.

  • chatgpt_model_key: Model used by the chatbot.

  • temperature: Controls response randomness (lower = more deterministic).

  • support_email: Contact email associated with the chatbot.

  • base_system_message: System prompt that defines the chatbot’s behavior.

  • conversation_starter_message: Optional starter message shown to users.

  • initial_message: First message the chatbot sends to users.

  • show_data_sources: Whether to show data sources in responses.

  • persistent_conversation_starter_message: Whether the starter message persists.

  • debug_mode: Whether debug information is enabled.

  • audio_io_enabled: Whether audio input/output is enabled.

  • image_upload_enabled: Whether image uploads are enabled.

Use these fields to understand and manage how your Chat Agent behaves in your application.

Was this article helpful?

Still need help?

Contact us