Custom Functions: Enhance AI Workflows with Third-Party Integrations

Custom Functions empower your AI Agent to execute advanced workflows by integrating with external data sources and APIs.

What are Custom Functions?

Custom Functions enable your AI agent to perform tasks such as:

  • Fetching live stock prices
  • Checking Shopify inventory
  • Retrieving data from Airtable or Google Sheets
  • Triggering webhooks or custom APIs

These functions are similar to creating a custom GPT function call.

How to Create a New Custom Function:

  1. Use ChatGPT or AI to generate the necessary Python/Flask code
  2. Set up a Google Cloud Project (if needed)
  3. Test your code using Postman or ReqBin
  4. Deploy your function (Replit, Render, or a server)
  5. Register your function within your AI Agent settings

Note: Available for Full SaaS Mode users only.

Example Use Cases:

  • Stock Market API Connection
  • Shopify Product Inventory Check
  • Airtable Data Retrieval
  • Google Sheets Employee Directory

Example - Google Sheets Custom Function (HR Example)

python
@app.route('/get_user_data', methods=['POST'])
def get_user_data():
name = request.json.get('name')

Google Sheets lookup logic here

  • User provides a name
  • AI retrieves all matching data from the sheet (Email, Location, Phone, etc.)

Code Generation Prompt for ChatGPT:

css
I want to create a custom function that retrieves [describe data] using [API or database]. It should accept [input_type] and return [output_type]. Provide complete Flask app code and JSON parameters.

JSON Parameters Example:

json
{
"parameters": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the user to look up in the Google Sheet."
}
},
"required": ["name"]
}
}

Example API Call:

python
schedule_appointment(email="user@example.com", desired_time_rfc3339="2024-11-04T09:30:00-08:00")

Testing Tip:

Use ReqBin or Postman to test your API endpoint before connecting it to the AI.

Example test endpoint:
arduino
https://your-replit-url/get_user_data

Final Step - Register the Custom Function in Your AI Agent:

  • Alias (Function Name): get_user_data
  • Endpoint URL: https://your-deployed-function-url
  • Description: Retrieve user data by name from Google Sheet
  • JSON Parameters: (as shown above)

Pro Tip: Once connected, your AI agent can fetch live data during conversations.