Chat Agent API Overview

Markdown

View as Markdown

The Chat Agent API lets you connect your Flora AI Chat Agent to other platforms so it can automatically converse with users and perform actions such as booking meetings. For example, you can connect the AI Chat Agent to your Facebook Page’s Messenger so it can respond to incoming messages and guide users through your booking flow.

This article explains the basics of how the API works and how to authenticate your requests.


1. What You Can Do with the Chat Agent API

With the Chat Agent API, you can:

  • Integrate the Flora AI Chat Agent into external messaging platforms (e.g., Facebook Messenger, custom web chat, mobile apps).

  • Automatically respond to user messages using your configured AI agent.

  • Use the agent to drive outcomes such as:

  • Booking meetings or appointments

  • Answering FAQs

  • Collecting user information (e.g., email, phone number)

  • Guiding users through predefined flows

The API acts as a bridge between your external platform and the Flora AI Chat Agent, allowing you to send user messages in and receive AI-generated responses out.


2. Authentication Basics

The Chat Agent API uses standard HTTP Authentication via an authorization header. Every request to the API must include a valid API key.

2.1 Authorization Header Format

Use the following header in your HTTP requests:

  • Header name: Authorization

  • Header value: Token {api_key}

Replace {api_key} with your actual API key.

Example:

Authorization: Token YOUR_API_KEY_HERE

If the Authorization header is missing or the API key is invalid, the request will be rejected.


3. Example Request with Authentication

Below are simple examples showing how to include the authorization header when calling the API from different environments.

3.1 cURL Example

curl -X POST "https://app.floraai.me/en/chatbot/api/v1/message/" \  -H "Content-Type: application/json" \  -H "Authorization: Token YOUR_API_KEY_HERE" \  -d '{    "message": "Hello, I would like to book a meeting.",    "user_id": "user-123"  }'

3.2 JavaScript (fetch) Example

fetch("https://app.floraai.me/en/chatbot/api/v1/message", {  method: "POST",  headers: {    "Content-Type": "application/json",    "Authorization": "Token YOUR_API_KEY_HERE"  },  body: JSON.stringify({    message: "Hello, I would like to book a meeting.",    user_id: "user-123"  })})  .then(response => response.json())  .then(data => {    console.log("Agent response:", data);  })  .catch(error => {    console.error("Error:", error);  });

4. Security Best Practices

  • Keep your API key secret. Never expose it in public repositories, client-side code, or shared screenshots.

  • Use environment variables or a secure secrets manager to store your API key on servers.

  • Rotate keys periodically and immediately if you suspect a key has been compromised.

  • Limit access to only the systems and team members that need the API key.


5. Summary

  • The Chat Agent API connects your Flora AI Chat Agent to external platforms so it can automatically talk with users and help them complete tasks like booking meetings.

  • All requests must be authenticated using an HTTP Authorization header.

  • Use the format: Authorization: Token {api_key} in every API request.

  • Handle your API key securely to protect your integration.

Was this article helpful?

Still need help?

Contact us