Skip to main content
You may want your users to provide the instructions for a new workflow. In this tutorial, we will show you how to convert user natural language instructions into a Simplex workflow.

Example

In this example, we will show you how to create a workflow from user prompts. Creating a workflow with our API also spins up a live session. This way, you can add agentic prompts live and add to a workflow simultaneously.
1

Obtain User Prompts

First, collect natural language instructions from your users. For example:
const userPrompts = [
  'Click on the Forms',
  'Open instructions for form {{form_number}}'
];
2

Create a Workflow from User Prompts

Use the collected prompts to create and execute a workflow:
import { SimplexClient } from '../src';

const userPrompts = [
  'Click on the Forms',
  'Open instructions for form {{form_number}}'
];

(async (prompts: string[]) => {
  // Initialize client
  const client = new SimplexClient({
    apiKey: 'YOUR_API_KEY'
  });

  // Create workflow session
  const workflow = await client.createWorkflowSession({
    name: 'tax-form-instructions',
    url: 'https://www.ftb.ca.gov/index.html'
  });

  console.log('Workflow ID:', workflow.workflowId);
  console.log('Livestream URL:', workflow.livestreamUrl);

  // Execute agentic tasks
  for (const prompt of prompts) {
    await workflow.agentic(prompt);
  }

  // Close session
  await workflow.close();
})(userPrompts).catch(console.error);