#Call a Flow from your application
Call the greeting from application code and use its message. The application chooses the input and checks the result. Jig runs the accepted method and accounts for its execution.
#Before you start
Complete Run your first Flow, including its review and approval.
Use Node.js 22 or newer.
Run every command below from the hello-jig directory.
No Agent or additional Flow is required.
Install Jig as an application dependency:
Use the same Jig release for review and application execution. This tutorial selects the application's installed executable explicitly. Run its review once to establish that selection:
Inspect and approve any changed revision. The network flag has the same preparation meaning as in the first tutorial.
#1. Call the accepted method
Create app.mjs:
inspect reads the approved target without reviewing live source.
expectedApproval prevents the call from silently selecting a different approval.
The request supplies input and bounded execution limits.
This method needs no file attachments or retained artifacts.
The persist callback records this task's complete prepared request before submission.
The helper waits for it, submits the unchanged request, and joins execution.
The exclusive file creation prevents another launch when you rerun this script unchanged.
The directory synchronization completes this local file example's persistence step.
In a durable application, persist Prepared with the task in one database transaction before submission.
Keep tickets and prepared input private.
They identify retained work and may contain sensitive input.
They do not grant authority.
#2. Use the result
After the greeting modification, expect:
The program requires successful execution, confirmed cleanup, the done outcome, and a string message.
These checks remain distinct.
A successful execution with a blocked outcome would not satisfy this application.
A schema-valid Agent answer could still need domain checks before a consequential action.
run() returns execution observations, rather than the method's output.
result() reads retained output without executing again.
Retention is bounded, so copy application data into your own store when needed.
See Application execution for artifact export and exact retention rules.
#3. Change one application input
Change input: 'Ada' to input: 'Grace'.
For this new task, change the record filename to greeting-002.json.
Then run node app.mjs again.
Expect Welcome, Grace!.
Changing application input needs no new Flow approval. Changing the method, its dependencies, or its project configuration needs review. Choose another task identity only for intentional new work, after resolving the previous task's state. Deleting a record or choosing a new filename does not make uncertain work safe to repeat.
#Recover after interruption
If the call loses its connection, read the saved task instead of creating another request.
Create recover.mjs beside app.mjs:
Use the filename recorded for the task you are recovering. This command observes retained state. It neither resumes a Flow nor submits another attempt. Missing history does not establish that execution never started.
For explicit cancellation, call client.cancel({ ticket: prepared.ticket }).
Acknowledgement confirms the request, rather than complete cleanup.
Read observations until the original owner settles.
If the original owner is gone and cleanup remains pending, you may explicitly
call client.reconcile({ ticket: prepared.ticket }) to acquire trusted recovery
of the saved attempt. It does not prepare, submit, resume, or retry the Flow.
An active owner or unconfirmed fence/cleanup refuses. Preserve the saved task
and inspect its original observation rather than retrying the execution.
Connection loss revokes owned execution but cannot undo remote effects already accepted by a provider.
Use Troubleshooting for approval errors, existing task records, uncertain execution, or unavailable output.
Next, choose an Agent for interpreted work, then compose methods. The application boundary stays the same when the accepted method uses code, Agent judgment, or both.