Blog

Software tips, techniques, and news.

Claris FileMaker AI Function Calling

As artificial intelligence continues to shape the future of technology, it becomes increasingly import to understand the impacts that AI integrations can have on an application. Integrating AI models and implementing function calling in FileMaker Pro can elevate an application to include a level of flexibility and dynamic ability that was beyond the scope of imagination just a few years ago. In this article, we’ll explore how AI function calling empowers developers to build more sophisticated and intuitive FileMaker solutions. Follow along to unlock the secrets of AI function calling!

youtube-preview

What is AI Function Calling?

AI function calling refers to the process of integrating artificial intelligence models into custom applications, allowing those apps to directly interact with an AI model for real-time processing and decision-making. In FileMaker Pro, this enables users to send inputs—such as text, numbers, or other data—to an AI model and receive relevant responses in real-time. By leveraging this technology, developers can automate complex tasks like advanced data manipulation or reporting. AI function calling simplifies the integration of large language models (LLMs) into FileMaker scripts, allowing users to build applications that respond intelligently to natural language queries, generate content dynamically, or analyze data patterns on the fly. In the next section, we'll explore some potential use cases for AI function calling in FileMaker Pro.

Use Cases

Now that we've discussed AI function calling, we can examine some real-world applications for this capability. Below are three examples of AI function calling demonstrating the capabilities of AI in FileMaker Pro.

Reporting

Reports are essential in today's business landscape. They provide data-driven insights that enable informed decision-making, help track performance, and support strategic planning, ultimately driving efficiency and competitive advantage. Running a report can be time consuming. Say you want to run a report that displays financial information for last month. You would need to navigate to the report generation layout, select the financial report you want to run, input the criteria for the report, and finally generate the report. With AI function calling, you can do that in one step. Instead of doing the above steps, you can simply ask your AI assistant to "show me a financial report for last month."

Financial Report User Query.

The assistant will determine that:

  1. You want to run a report

  2. The report should be the financial report

  3. The report should generate financial information about the previous month

The AI assistant will then be able to run a financial report for last month by calling your financial report script with the specified parameters, eliminating the manual entry steps previously required!

Last Months Financial Report.

Record Management

FileMaker databases contain hundreds of thousands, sometimes millions, of records. With so many records, it's not unrealistic for things for occasionally fall through the cracks. For example, let's say that you have an invoice module in your application and you want to make sure that invoices are not falling by the wayside. Rather than creating a complex find query, you can prompt your AI assistant to show you records that are overdue or pending. You could tell the assistant to "show me invoices that are overdue or that are pending."

AI Invoice Status Query.

With this query, the assistant will determine:

  1. You want to view invoices

  2. The invoice records need to have a status of "Overdue" or "Pending"

With this criteria, the assistant can call a find script you have defined using the criteria you provided as the parameters. After it's all said and done, you can now see invoices records that are overdue and need payment or have been send and are waiting on payment, therefore preventing things from falling through the cracks!

Invoice Status Response.

Layout Navigation

Layout navigation can be a tedious process if you are looking to go to a layout that may not be used very often. For example, say DB Services created your FileMaker application, and you would like to view information about the company. This information layout is likely deeply nested in a setup module. You might need to go to Setup → Preferences → Information → DB Services. This process might be obscure for a user unfamiliar with the system. With AI function calling, you can simply open the wizard and type "Go to the DB Services information layout."

filemaker AI Function Calling Go to Layout Request.

The AI model will determine that you would like to view information about DB Services and will bring you to that layout without you having to follow that long navigational chain!

filemaker AI Function Calling Go to Layout Result.

How It Works

AI function calling is a really neat capability and process, but how does it actually work, and how can you implement it into your FileMaker application? Follow along to learn to integrate AI function calling into your system! In this demonstration, we will be using OpenAI's gpt-4-1106-preview and gpt-3.5-turbo LLMs (Large Language Models) and will be following the OpenAI function calling guide.

Pre-Requisites

First, you will need to create an OpenAI account. Once you have an account, click the API Keys tab in the left navigation bar and generate an API Key. Make sure to save your API Key before leaving this window, as it will not be available to view later. Next, you will need to define functions and scripts in your application that can be passed to the model as options. For example and explanation purposes, we will be focusing on the layout navigation use case shown in the previous section, but you can download our demo file to see examples of what other definitions might look like.

AI Function Calling Lifecycle

At a high level, the OpenAI AI function calling lifecycle is broken up into five steps.

  1. Your application will call the API with the prompt and definitions of functions that the LLM can call.

  2. The model decides whether it should respond to the user or whether one or more functions should be called.

  3. The API then responds to your application with the function to be called and the arguments the function should be called with.

    1. An important note for this step is that the model never actually executes functions itself, rather the model generates parameters that can be used to call your function. This means that your application is always in full control and it is up to you to determine how to handle the supplied parameters, likely by calling the indicated function.

  4. Your application executes the given function with the supplied arguments.

  5. Your application calls the API with the prompt and the result of the function your code just executed.

OpenAI Function Calling Diagram.

Let's break these steps down and explain how to successfully implement them into your FileMaker application.

Step 0: Application Setup

In our demo file, we have created a few different tables to assist us with function calling, and we recommend that you do the same. The "FUNCTION" table contains function definitions and is where information about the function lives. The "FUNCTION_ARGS" table contains information about the arguments (parameters) that should be passed to a function, such as name, description, and type. The "SYSTEM" table contains information about how the AI model should operate and respond within our application. We also recommend that you add a table for housing API call log records, "LLM_LOG" in our demo file, so that you may keep a history of each individual API call. This is not necessary, but it is strongly recommended.

Step 1: First API Call

The first thing we need to do is choose a function that we would like the model to generate arguments for. We'll start with our layout navigation function. We need to describe our function to the model, so we'll build a function definition JSON object that looks like this:

filemaker ai function calling Function Definition JSON Object.

We then can add that function definition object to a "tools" array. Next, we build our "messages" array, which includes the role of the system and the user prompt. That looks something like this:

filemaker ai function calling Tools Array.

Finally, we can build our payload object that we will use when calling the API. Everything put together looks like this:

filemaker ai function calling cURL Payload.

With the payload built, we then make our API call and log the results.

Step 2: Get API Response

Depending on what you ask the AI assistant to do, you'll get different responses. Since we asked the AI assistant to bring us to the DB Services information layout, a function call will be necessary. The LLM will determine that and will give us a response that looks like this:

filemaker ai function calling AI Response Object.

After parsing the response, we can see that the response's message "content" is null. This means the LLM has determined one (or more) of the functions that we passed in via the "tools" array should be executed.

Step 3a: Execute Function(s)

If the LLM determines that a function call is necessary, you will need to get the functions from the returned list and execute them within your code. The functions to be executed can be found under the "tool_calls" section from the API response. In this case, the only function that should be called is the "GoToDBInfoLayout" function. We can then run the script that is associated with the function, and that's it!

filemaker ai function calling Script Execute Functions.

Step 3b: Display AI Response

The LLM does not always determine that a function call is necessary. In cases that don't require user developed scripting, the LLM can resolve the query itself and does not need you to run a function in your code. If that is the case, you will see that the response's message "content" is not empty or null, and you can just display the content!

filemaker ai function calling Script Show AI Response.

Conclusion

AI function calling in FileMaker Pro revolutionizes how developers approach complex automation and intelligent data handling. By integrating these powerful AI tools directly into applications, FileMaker enhances the efficiency and intelligence of user workflows. The ability to automate tasks like reporting, record management, and navigation, all while responding to natural language, opens up a new frontier for FileMaker developers looking to build sophisticated and dynamic solutions. As AI continues to evolve, the opportunities for innovation within FileMaker apps will only expand, empowering developers to create more intuitive, adaptive applications. If you'd like to implement AI function calling into your FileMaker system, contact us at DB Services and we would be happy to help.

Did you know we are an authorized reseller for Claris FileMaker Licensing?
Contact us to discuss upgrading your Claris FileMaker software.

Download the FileMaker AI Function Calling File

Please complete the form below to download your FREE FileMaker file.

First Name *
Last Name *
Company
Email *
Phone *
FileMaker Experience *
Agree to Terms *
grant gonzalez headshot.
Grant Gonzalez

Grant is a friendly and enthusiastic developer who is quick to offer support to others. His desire for connection fosters positive relationships with both coworkers and customers, and his optimistic mindset helps build team spirit and aligns with DB Services’ core values: making a positive difference in customers’ lives.