Search code examples
elsa-workflows

How to run a workflow with parameters


I'm new using Elsa and I try to run a hello world example. When we need to call the workflow, we just need to call this sentence:

await runner.BuildAndStartWorkflowAsync<HelloWorld>()

I'm wondering for example how I can call the HelloWorld class but sending some parameters that are coming from outside.

BuildAndStartWorkflowAsync has some parameters, one of them is input of type WorkflowInput, which I assume is used to send values to the workflow. Once I call the workflow, it goes to the HelloWorld/Build method, how can I read this input from there?


Solution

  • The way of calling the workflow with initial parameters it is:

    await runner.BuildAndStartWorkflowAsync<HelloWorld>(input: new WorkflowInput(yourobject));
    

    where "yourobject" is whatever you want, a class for example with some properties.