Document your own triggers and actions for AutoFlow Intelligence
This guide is for developers of Business Central apps that add their own triggers or actions to AutoFlow – vendor apps and per-tenant extensions.
AutoFlow Intelligence works with every trigger and action installed in the environment, not only with the AutoFlow ones. Before it configures a step, it reads that step's documentation. Your app hands it over when AutoFlow asks for it. If your app does not answer, AutoFlow Intelligence describes the step from what it can see – its description, its settings on the configuration page, its outputs and the settings used in existing flows – and marks that page as auto-generated. That works, but the model has to guess more, so documented steps give much better results.
AutoFlow Intelligence only uses the steps the flow designer could pick in the editor. If your app hides a step with OnFilterActions (for example while it is not licensed), the AI does not offer it either, and the checks your app runs at publish (OnValidateFlowStep) are already applied while the AI builds the flow. The flow is not saved yet then: FlowVersionId is 0, so read the step from Configuration and Definition, not from the database.
What you provide
For every trigger and action your app adds:
- A page – English markdown, written for the model: what the step does, every setting with its key and allowed values, the outputs, a short example of the step in a flow definition, and pitfalls. The pages in the AutoFlow agent docs show the shape.
- A spec (optional, recommended) – a JSON object in the format of
spec/_FORMAT.md:kind(actionortrigger),id(the enum value's ordinal),name, the configuration keys with types and defaults, the outputs, and rules. AutoFlow Intelligence checks every flow it builds against the rules, so they catch mistakes before the user sees the draft.
How to hand it over
AutoFlow Core raises two events on codeunit mse365 AF-CO Config. Mgt.:
OnGetActionAgentDocs(Action; var Docs; var Spec; var Handled)OnGetTriggerAgentDocs(EventTrigger; var Docs; var Spec; var Handled)
Subscribe to them in your app and answer for your own enum values only:
codeunit 50100 "ACME Step Agent Docs"
{
Access = Internal;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"mse365 AF-CO Config. Mgt.", 'OnGetActionAgentDocs', '', false, false)]
local procedure OnGetActionAgentDocs(Action: Enum "mse365 AF-CO Action"; var Docs: Text; var Spec: Text; var Handled: Boolean)
begin
if Handled then
exit;
case Action of
Action::"ACME Send Shipment":
begin
Docs := SendShipmentPage();
Spec := SendShipmentSpec();
end;
else
exit;
end;
Handled := true;
end;
local procedure SendShipmentPage(): Text
var
Tb: TextBuilder;
begin
Tb.AppendLine('# Send shipment (ACME)');
Tb.AppendLine('');
Tb.AppendLine('Sends the shipment of a posted sales shipment to the ACME carrier portal.');
// ...
exit(Tb.ToText());
end;
local procedure SendShipmentSpec(): Text
begin
exit('{"kind":"action","id":50100,"name":"SendShipment","configuration":[],"outputs":[],"rules":[]}');
end;
}
Rules for the subscriber:
- Start with
if Handled then exit;and setHandledonly for values your app declares. - No pages, dialogs or messages, no database writes and no errors – AutoFlow asks while the AI works in the background.
- Build long texts with a
TextBuilderfrom string parts of at most 1,000 characters each. That compiles on every Business Central version AutoFlow supports. - AutoFlow only asks when the AI needs the step, so the cost is small. Nothing is stored.
We keep our own pages as .md and .json files next to the app and generate the subscriber codeunit from them in the build. You do not have to – but if your steps change often, it keeps the docs easy to review.
Test it
Call the same function AutoFlow Intelligence uses and check the answer:
Assert.IsTrue(ConfigMgt.GetActionAgentDocs(Enum::"mse365 AF-CO Action"::"ACME Send Shipment", Docs, Spec), 'documented');
Assert.IsTrue(SpecObject.ReadFrom(Spec), 'spec is JSON');
Then start AutoFlow Intelligence with a request that needs your step. In the session log (AutoFlow Intelligence Setup → Sessions) you see the step's documentation being read.