Skip to main content

Function Code Anatomy

With your function project made and the code available on GitHub, you can start making it your own. Where you choose to develop (locally or codespace) is up to you. Assuming you work locally, clone the repository linked under Source on the function’s page; the sections below cover the code architecture.
.githubThis directory is for automations used to keep your function code up to date and ease the publishing process.
  • dependabot.yml.: This specification keeps track of GitHub actions used and will recommend updates when necessary.
  • workflows/main.yml: When you make a Release of your function code, this action will trigger and publish a revision to Speckle Automate
Leave that automation in place unless you have a custom release pipeline.
The template projects for specklepy and speckle-sharp include all required for a working function to deploy in an automation. The anatomy doesn’t have to match exactly, but it does have to have these key components:

Function Inputs

Python

This is a FunctionInputs class subclassing AutomateBase from the Python Automate SDK (speckle_automate, part of specklepy). Define its properties with Pydantic Field objects to control the fields shown in the function inputs UI. A SecretStr field is a secret: Automate masks it in the UI and stores it encrypted.
main.py

C# (.NET)

FunctionInputs must be a struct.
FunctionInputs.cs

Secrets Management

It is possible to flag function inputs so that the Automate UI will obfuscate them on entry in the typical web fashion (********). This will also cause Automate to store these as encrypted and only pass them as plain text within AutomationContext at runtime.

C# (.NET)

FunctionInputs.cs

Python

main.py

Run Entry Points

In the GitHub action, there is a space to define the eventually built function as it would be executed from a command line with either dotnet SpeckleAutomateDotnetExample.dll or python main.py run, which is the general rule for all Automate functions, whether defined with the template projects or not.

Python

The essential execution of a Python SDK function is:
main.py
FunctionInputs is the class described earlier, and automate_function is the single entry point to your business logic. Define it with plain def, not async def: the runner calls it synchronously, so a coroutine would never run. You can define as many classes, external modules, and functions within your repository code, but this will be your key function.

C# (.NET)

The template’s Program.cs registers the Automate SDK, resolves the runner, and passes it your function:
Program.cs
FunctionInputs is the struct described earlier. AutomateFunction is a class with a Run(IAutomationContext context, FunctionInputs inputs) method that returns a Task. It can hold all of your business logic, or be the entry point to the rest of your classes and methods.
You may rename and restructure your function code as you wish as long as these execution entry points are followed. However, it may make sense to adopt the template’s structure to debug easily and allow others to follow the flow.The main .csproj for dotnet functions should be renamed to reflect your function name; make sure to adjust the workflow/main.yml file to reflect this.

Testing

Functions must be registered to Automations to trigger by events. It is recommended that you implement a structure of your project such that a lot of the business logic can be tested independently of the specifics of both the Automate environment and the Speckle data triggering the events. To run your function locally against live project data, see Testing Your Functions.
Last modified on October 19, 2026