AI Accelerator, Custom function
Describe the function you need in the Accelerator chat and it writes the C# method body and the [CustomFunction] attribute, ready to save into the Custom Functions UI.
Custom functions look simple but they’re sensitive to two kinds of detail the Accelerator can’t infer: the exact signature the call sites expect, and any external dependencies (a database, a third-party API, a NuGet package) the function will reach out to. Both are worth putting in the prompt, because a function with the wrong signature does not fit its call site and a function that quietly hardcodes a connection string is not one you can promote between environments.
None of the following is required. A one-line request still gets you a function. These are the facts the Accelerator cannot infer, so each one you include is one it does not have to guess:
- The function name, the [CustomFunction] token callers will reference.
- The parameters, name, type, and what each one represents.
- The return type, and what an empty / null / error result should look like.
- The behaviour, described in plain language, including edge cases.
- Any external dependencies, database connection, HTTP endpoint, NuGet package, and how they should be configured (parameter vs. constant).
- Where the function will be called from, map, port property, pipeline component property, or routing expression, so the Accelerator can shape error handling appropriately for the call site.
The C# itself you can leave to it. Spend the prompt on the contract and the dependencies.
A request like this states all of it and gets the function back in one pass. Note the null-result behaviour and the call site, both stated rather than left open:
Write a custom function named LookupWarehouseCode that takes one string parameter, a plant id, and returns the matching warehouse code as a string. Read it from the WarehouseMap table on the OpsDb SQL connection, and return an empty string when no row matches. Expose the connection string as a parameter rather than hardcoding it. It will be called from a map binding.