Cookbook 05: Your users stay in control
Let an AI prepare a DocuSign agreement, then hand control to the person who signs. See the recorded Pine Computer example and Ruby code.
By The Pine Computer team · Updated
The recorded task has a precise stopping point: fill the NDA’s six ordinary fields and leave its signature untouched. The agent signs in to the DocuSign developer sandbox, opens the agreement and fills the effective date, company name, address, printed name, title and date. It checks those values and stops before signing or submitting.
The application then notifies the signer. The person takes control of the same computer and completes the signature. Keeping the document open lets them review the prepared agreement before acting.
Where the application takes over
The Ruby below is the excerpt shown in the recording. It assumes an existing computer, sign-in credentials and the demo’s helper code. follow waits for the agent’s run; notify_human represents notification logic supplied by the demo application. It is not a built-in Pine messaging service, and gets is a terminal pause rather than confirmation that the document was signed.
The Ruby below is an excerpt from the October recording, not a current integration recipe. SDK setup and application helpers are omitted. Use the current agent API and file handling docs when building an integration.
session = computer.create_session(browser: true)
secrets = { "EMAIL" => ENV["DOCUSIGN_EMAIL"], "PASSWORD" => ENV["DOCUSIGN_PASSWORD"] }
session.agent.run(<<~GOAL, secrets: secrets)
Sign in to DocuSign as $EMAIL with $PASSWORD.
Open the NDA that needs to be signed and fill in every field.
Leave the signature to the user.
GOAL
follow(session) # the run stops; your code has it back
session.notify_human(reason: "signature") # your app texts or calls the user
puts "Ready to sign. Handing over."
gets # and waits while they signKeep preparation and signature separate
There are three different results to track in an application:
- Prepared: the expected fields contain the intended values and the signature is still blank. The person can review the agreement.
- Waiting for the signer: the notification has been sent and the person can open the live desktop. Sending that notification does not finish the job.
- Signed: DocuSign shows the completed result. Record the document’s reference or retrieve the completed document before closing the job.
The recording demonstrates the transition from preparation to human control. The excerpt does not implement durable job storage, notification delivery, reconnect handling or a final signed-document check. Those are parts of the application around this example.
Handle a return to the document
If the person closes the browser or the connection drops, open the same pending agreement and inspect its status before restarting the preparation. A document that has already been signed should not be sent through the fill-and-sign sequence again.
Use the Web SDK to embed the desktop and manage control. The agent documentation covers requests for input and turn outcomes. A completed agent turn means its work ended; the agreement’s status is the evidence that the signature step finished.