Mock API Connections
You can mock the API connections using Mock APIs.
GenerativeAgent supports Mocking API Connections to try out your raw API responses. Mock API Functions let you define request parameters (in JSON) without needing a live API.
The main benefits of mocking API connections are:
- Rapid prototyping of new Functions without a fully built API.
- Testing how GenerativeAgent processes or populates request parameters before real integration.
- Simplifying configuration for teams that want to get interacting with GenerativeAgent quickly before building or exposing internal APIs.
Create a Mock API Function
Navigate to the “Functions” Page in the main GenerativeAgent menu and select “Functions.”
-
Click on “Create Function”
-
Choose “Integrate Later”
- You will be prompted to select an existing API or “Integrate later.”
- Select “Integrate later” to mark this Function as a Mock API and define the request parameters directly.
-
Name and Describe the new Function
- Function Name: Give it a concise, unique name
- Function Purpose: Briefly describe what the Mock Function is for
Example:
- Name: “get_flight_details”
- Purpose: “Retrieves flight information given a PNR”
-
Define Request Parameters (JSON)
- Under “Request parameters,” enter a valid JSON schema describing the parameters you want.
- You can pick a template from the “Examples” dropdown or start with an empty JSON schema.
- Example Request
Make sure the JSON is valid. Invalid schemas are prevented from being saved.
-
Save Your Function
- Click “Create Function” (or “Save”). If any part of your schema is invalid, an error will appear.
- After saving, you remain on the function detail page, which shows the Function’s configuration and preview.
You can configure additional fields and variables if you need prompts or placeholders in the conversation flow.
For example: “Message before sending”, “Confirmation Message”, “Reference Variables”
Best Practices
Here are some recommendations to help you make the best use of the Mock API feature:
Connect to a real API
When you are ready to connect the Function to an existing API in the Console:
- Click on “Replace” on the Function detail page.
- Select an existing API connection or create a new one.
- Once replaced, the Function will call the real API during interactions instead of the Mock schema.
Was this page helpful?