Watch the walkthrough
Create reusable server-side functions and call them from workflows.
Recorded with an earlier Twidget interface. Names, control locations and available options may differ; use the linked documentation for current guidance.
Watch tutorial (3:13)
Browse all video tutorials
In Twidget, you can build custom reusable functions. These functions can be utilized across various sections including endpoints, events, and other functions. Instead of creating the same commands repeatedly, you can create a function once and reuse it wherever necessary, making your workflow more efficient and maintainable.
Constructing Functions
Functions in Twidget are structured similarly to endpoints. However, instead of using typical endpoint inputs such as query, headers, and body, functions use data type inputs.
Output
Each function also has an optional output. To simplify the use of functions, you can define an output schema. The output schema acts as an internal documentation detailing what the output of the function will look like. This makes it easier to understand and utilize the function correctly.

Managing Custom Functions
All custom functions you've created can be viewed in the Your Functions section of the Add Commands sidebar. This centralized view allows you to easily manage and access your reusable functions.

Using Custom Functions
When you need to use a custom function that has inputs, you will be prompted to enter the required inputs in the Commands sidebar. This ensures that the function has all the necessary data to execute correctly.

Run shared logic automatically
Use Reusable Middleware when shared logic should run before or after endpoints, functions or events, including through workspace defaults. Use an ordinary custom function when you want to choose its call explicitly inside your command list.
Save a reusable starting point
Use Workflow templates to keep a function and its supported dependencies in your workspace library. Installing a template creates independent unpublished copies that you can adapt and test before publishing.