Articles in this section
Category / Section

Create Custom Variables

3 mins read
Updated:

Here’s a step-by-step tutorial based on how to create and use variables in FlowMattic.

Step-by-Step Guide: Creating a Custom Variable in FlowMattic

Step 1: Navigating to the Variables Section

  1. Login to FlowMattic and access your dashboard.

  2. In the left-hand menu, click on “Variables”.

  • This will take you to the Variables Management screen where you can see a list of previously created variables or create new ones.

Step 2: Creating a New Variable

  1. On the Variables screen, click on the “Add New Variable” button (usually located at the top of the page).

  2. A form will appear, prompting you to fill in the details for the new variable.

  • Variable Name:

    • Enter a unique and meaningful name for your variable (e.g., current_time or user_id).
  • Variable Value:

    • This field accepts a plain text value, dynamic placeholders, or even a PHP function. For example:

    • Entering PHP:time() as the value will dynamically call the time() function whenever this variable is accessed in your workflow, returning the current Unix timestamp.

    • Similarly, you can use other PHP functions like PHP:date("Y-m-d") to return a formatted date.

Step 3: Using PHP in Variables

  • FlowMattic supports PHP functions directly in the Variable Value field, which is extremely useful for dynamically generating data.

  • Example:

  • If you input PHP:time() as the variable value, FlowMattic will evaluate the PHP code when the variable is accessed in the workflow.

  • This ensures that the value is always current and generated at runtime.

Step 4: Saving the Variable

  1. After entering the Variable Name and Variable Value, click on “Save” or “Create”.
  • Your variable will now appear in the list of available variables, and its value will be updated each time it is accessed in workflows.

Step 5: Using the Variable in a Workflow

  1. Navigate to the Workflows section of FlowMattic.

  2. When creating or editing a workflow, locate the step where you wish to use the variable.

  • Most fields that accept dynamic data (such as messages, emails, or API requests) will allow you to insert variables.
  1. Click the “Database” icon or in the input field to bring the dynamic data dropdown, then find the variable in the “Variables” toggle. OR type the variable name (e.g., {{variable_name}}) where you want to use the variable.
  • If you created a variable with a PHP function (e.g., PHP:time()), this function will be called and evaluated dynamically when the workflow is triggered.

Step 6: Testing Your Variable

  1. Run your workflow and check the output to ensure that the variable works as expected.
  • For example, if you used the PHP:time() function, the workflow should output the current Unix timestamp wherever you used the variable.

Example Use Case

  • Current Timestamp Variable:

  • If you create a variable current_time with the value PHP:time(), you can use this variable in an email, API request, or other workflow step to always have the exact timestamp when the workflow runs.

  • Formatted Date Variable:

  • If you want the current date in YYYY-MM-DD format, you can create a variable with the value PHP:date("Y-m-d").

Conclusion

By following these steps, you can effectively create and manage custom variables in FlowMattic, using PHP functions for dynamic and real-time data processing in your workflows. This is especially useful for automating tasks that rely on up-to-date information like timestamps, dates, or other PHP-based calculations.

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Access denied
Access denied