Connect your chatbot to external APIs to fetch or send data, enabling complex interactions and providing users with dynamic information.
When creating a new connection (via "Dashboard" > "API Connections" > "New Connection"), look for the"Ask AI to create a configuration" button. You can describe the API you want to connect to in plain language, and the AI will attempt to automatically fill out the connection details and parameters for you.
Important: While this can significantly speed up setup, you MUST always:
An API Connection defines how your chatbot interacts with a specific external API endpoint. These are the core details you{'''}ll configure:
Assign a clear, descriptive name (e.g., "Get User Orders","Weather API"). This helps both you and the AI identify the connection's purpose.
Crucial for functionality. Provide detailed instructions for the AI on when and how to use this API. Explain the API's purpose and the specific types of user requests or conversational contexts that should trigger its use.
Example: "Use this API to fetch order details when a user asks about the status of a specific order. Requires an order ID."
Select the HTTP method (GET, POST, PUT, DELETE, PATCH) that the external API endpoint expects for this specific action.
Enter the full URL of the API endpoint (e.g., https://api.example.com/v1/users/{userId}/orders
).
If your URL contains placeholders enclosed in curly braces (like {userId}
above), these will be automatically detected as Path Parameters.
You will configure how the AI obtains values for these path parameters in a separate section below the main parameters. Unlike Query or Body parameters, Path Parameters are defined by the URL structure and cannot be manually added or changed to a different type ('Send In').
Configure how your chatbot authenticates with the API. Your credentials are stored securely.
X-API-Key
) and the Key Value.Toggle this switch to activate or deactivate the connection. Disabled connections won't be used by the AI.
Parameters are the data sent along with your API request. There are two main types: Manually Added Parameters (sent in the Query String or Request Body) and Detected Path Parameters (part of the URL).
Use the "Add Manual Parameter" button to define data sent as Query Parameters or within the Request Body.
The exact name the API expects (e.g., searchQuery
, product_id
). Must contain only letters, numbers, and underscores.
Choose how this parameter is sent:
?limit=10&offset=20
). Typically used with GET requests.Define where the chatbot gets the value for this parameter:
Provide clear instructions for the AI (e.g., "Extract the city name mentioned by the user for the weather lookup", "Find the 8-digit tracking number from the user's message").
Specify the exact key from your context object (e.g., userId
, userEmail
). Must contain only letters, numbers, and underscores.
Toggle whether this parameter is essential for the API call. If required and the value cannot be obtained, the API call may fail or be skipped.
If your Endpoint URL includes placeholders like {placeholder}
, they appear here automatically. You only need to configure their Source (how the AI gets the value).
Automatically determined from the URL placeholder (e.g., userId
if the URL contains {userId}
). This cannot be changed here.
Define where the chatbot gets the value for this path segment. The options are the same as for manual parameters:
Toggle whether this path parameter is essential. If required and the value cannot be obtained, the API call will likely fail.
After creation, API Connections are listed in the dashboard. You can edit the connection details, view configured parameters, and manage them.
When you configure API parameters with the source From Provided Context (JS API), you need to provide the user context data through your website integration. This allows your API calls to use personal data like user IDs, email addresses, subscription status, or any other user-specific information.
The chatbot exposes a window.easyfindai.setContext()
function that accepts a single argument: a JavaScript object (\`userData\`). This object can contain any key-value pairs you need, as long as it can be serialized to JSON.
When you configure an API parameter with the source "From Provided Context (JS API)", you must specify a "Context Key Name". The system will then look for a key inside the \`userData\` object you provided via \`setContext()\` that exactly matches this"Context Key Name". The corresponding value will be used for the parameter.
Add this script after your chatbot embed script:
<!-- Place this script tag AFTER the chatbot embed script --><script>// Function to attempt setting contextfunction setEasyFindAiContext() {// Check if the chatbot API is readyif (window.easyfindai &&typeof window.easyfindai.setContext === "function") {const userData = {userId: "user_123456", // Example: Get from your auth systememail: "user@example.com", // User's emailplan: "premium", // Subscription level// Add any other fields your APIs might need};window.easyfindai.setContext(userData);console.log("User context sent to EasyFindAi chatbot");} else {// If not ready, wait a bit and try againconsole.warn("EasyFindAi context API not available yet, retrying...");setTimeout(setEasyFindAiContext, 500); // Retry after 500ms}}// Call when the page loadsdocument.addEventListener("DOMContentLoaded", setEasyFindAiContext);</script>
Create a Client Component to set the context:
// components/ChatbotContext.tsx"use client";import { useEffect } from "react";import { useUser } from "@/hooks/useUser"; // Your user data hook// Define window interface with chatbot propertiesinterface ExtendedWindow extends Window {easyfindai?: {setContext?: (data: any) => void;};}export function ChatbotContextSetter() {const { user } = useUser(); // Your hook to get authenticated useruseEffect(() => {// Only proceed if we have user dataif (!user) return;const win = window as ExtendedWindow;// Function to set context with retry logicconst setContext = () => {if (win.easyfindai?.setContext) {win.easyfindai.setContext({userId: user.id,email: user.email,plan: user.subscriptionTier,// Add any other relevant user data});console.log("Context set for chatbot");} else {// Retry if the chatbot hasn't loaded yetsetTimeout(setContext, 500);}};setContext();}, [user]);// This component doesn't render anythingreturn null;}// Use in your layout or page component:// <ChatbotContextSetter />
While the method is the same (window.easyfindai.setContext(userData)
), how you access user data and run this JavaScript depends on your specific website platform or framework (e.g., WordPress, Shopify, Wix, vanilla JS). Use the prompt template below to ask an AI assistant for guidance specific to your setup:
I need help setting the user context for the EasyFindAi chatbot on my website.My website is built using: [Specify your framework/platform, e.g., WordPress with Elementor, Shopify (Liquid theme), Vanilla JavaScript, React, Angular, Vue, etc.]The goal is to call the JavaScript function `window.easyfindai.setContext(userData)` after the chatbot script loads.The `userData` object needs to contain specific key-value pairs. The **keys** in this object MUST exactly match the "Context Key Name" I will configure for my API parameters in EasyFindAi.Here are the keys I need in the `userData` object, and where the corresponding values come from in my application:* Key: "[e.g., userId]" - Value Source: [Describe where to get this value, e.g., 'A global JavaScript variable `myAppData.userId`', 'A data attribute on the body tag']* Key: "[e.g., userEmail]" - Value Source: [Describe where to get this value, e.g., 'A global variable `myAppData.userEmail`', 'Need to fetch it via an internal API']* Key: "[e.g., subscriptionTier]" - Value Source: [Describe where to get this value, e.g., 'A variable `myAppData.plan`']* [Add any other required key-value pairs and their value sources]Please provide a code snippet or steps specific to [Your Framework/Platform] showing how to:1. Reliably access the data needed for the values listed above.2. Construct the `userData` JavaScript object using the **exact keys** specified above.3. Call `window.easyfindai.setContext(userData)` safely after the chatbot has loaded, ensuring the `window.easyfindai` object and `setContext` function exist (e.g., using checks or retries).
setContext()
.