Catalytic for Developers

Welcome, developers

Catalytic speaks your language. Our developer tools allow you to code, customize and create more with our platform.

Get Started    

Instances

When you start a Workflow, you create an Instance. That Instance contains data stored in fields and tracks the status of your automation workflow. Each Step in your Workflow becomes a Step in your Instance.

The Instances client allows you to start and stop Instances, find and get data from your Instances and complete steps in your Instances. It provides the following methods:

MethodDescription
Get
GetAsync
Gets a specific Instance by Id
Find
FindAsync
Search for Instances by Name or Owner
Start
StartAsync
Start an Instance of a Workflow
Stop
StopAsync
Stop an Instance
GetStep
GetStepAsync
Get an Instance Step by ID
GetSteps
GetStepsAsync
Get all Steps of an Instance
FindSteps
FindStepsAsync
Find Steps across all Instances
CompleteStep
CompleteStepAsync
Complete a Step

Quickstart Example

/*
 * This example demonstrates finding a Workflow, starting an Instance of
 * that Workflow with some inputs, getting data from the Instance and
 * finally completing a Step in the Instance.
 */

using Catalytic.Sdk;
using Catalytic.Sdk.Entities;
using System;
using System.IO;

namespace Catalytic.Sdk.Examples
{
    class Program
    {
        // update this to your email before running this sample
        public const string YourEmail = "[email protected]";
      
        static void Main(string[] args)
        {
            // create and initialize the Catalytic SDK Client
            var catalytic = new CatalyticClient(Credentials.Default);

            // find workflows matching "Sdk Example Workflow"
            var matches = catalytic.Workflows.Find(
                Where.Text.Matches("Sdk Example Workflow"));

            // `matches` is a results page containing `Workflows` and 
            // a `NextPageToken` you can use to page through results.
            // We only expect one match for this example so we can simply
            // get the first matching Workflow.
            var pushbot = matches.Workflows.FirstOrDefault();

            if (workflow == null)
            {
              workflow = catalytic.Workflows.Import(
                  new Uri("https://push.bot/sdk-example"));
            }

            // Now that we've got our workflow, let's set the inputs it expects
            var request = workflow
              .SetInput("Age", 42)
              .SetInput("Name", "Alice")
              .SetName($"SDK Example - {DateTimeOffset.Now.ToString()}");

            // Start the workflow
            var instance = catalytic.Instances.Start(request);

            // get the step we want to complete
            var steps = catalytic.Instances.GetSteps(instance.InstanceId).Steps;
            var uploadStep = steps.Where(
                s => s.Name == "Upload Updated Spreadsheet and Set Email").First();

            // download the Data Table from the "Table" field as a CSV 
            var tableId = instance.Fields["Table"].GetValue<Guid>();
            var csvFile = catalytic.DataTables.DownloadFile(tableId, DataTableExportFormat.CSV);

            // Do our "business logic" to transform the csv data
            // As a simple example, we replace "Foo" with "Bar"
            var updatedCsvContent = csvFile.OpenText().ReadToEnd().Replace("Foo", "Bar");

            // create the output csv file locally
            var updatedCsvFile = new FileInfo(Path.GetTempFileName());
            File.WriteAllText(updatedCsvFile.FullName, updatedCsvContent);

            // To complete the step, we will set both a text and a file field
            var stepRequest = step
              .SetInput("Updated CSV", updatedCsvFile)
              .SetInput("Email Address", YourEmail);
            catalytic.Instances.CompleteStep(stepRequest);

            Console.WriteLine($"You should have an email waiting for you at {YourEmail} now with the updated CSV converted to an Excel attachment");
        }
    }
}

Updated a day ago

Instances


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.