Close Won in HubSpot when a Docusign contract is signed

When an envelope completes, mark the matching HubSpot deal Closed Won, file the signed PDF in Google Drive, and post the win in Slack.

Agentic Task
DocusignHubSpotGoogle DriveSlackSalesOperationsData SyncNotifications & AlertsDocument Processing

Build me an agent workflow that closes out HubSpot deals automatically when the signed contract comes back through Docusign.

Trigger: a Docusign poll on envelope_status_changed, filtered to envelopes whose status just transitioned to completed. Ignore sent, delivered, declined, voided, and any other status.

When the trigger fires, the agent should do the following, reasoning carefully because envelope-to-deal matching is fuzzy in real life (signer email may not match the primary contact, company names vary, there may be more than one open deal):

1. Pull the envelope context from Docusign. Call Get Envelope to get the envelope subject, completion timestamp, and any envelope-level custom fields. Call List Recipients to get every signer's name, email, and company. Call List Envelope Custom Fields if needed for any deal id or HubSpot reference the sender stamped on the envelope.

2. Find the matching HubSpot deal. First check whether the envelope custom fields already carry a HubSpot deal id (the cleanest case). If not, use HubSpot Search Contacts on each signer email, then HubSpot Search Companies on the company name as a fallback, then HubSpot Search Deals filtered to open stages and associated with those contacts or companies. Prefer deals that are in a late pipeline stage and have an amount close to anything mentioned on the envelope. Be honest about uncertainty: if the best candidate is not a clear winner, do not guess.

3. If a confident match is found, call HubSpot Update Deal to set the deal stage to Closed Won (using the configured pipeline and stage id) and set the close date to the envelope's completion timestamp.

4. Grab the signed PDF. Call Docusign List Envelope Documents, pick the combined or signed document, then call Download Document to get the PDF bytes. Upload it to Google Drive into a configurable Signed Contracts folder using Upload File (Multipart) for files under 5MB or Upload File (Resumable) for larger files. Name the file clearly, for example using the deal name and close date. Capture the resulting Drive file's web view link.

5. Post a Slack Send a Message in the configured sales channel summarizing the win: deal name, amount, signer names and emails, the company, the new stage, the close date, and a link to the signed PDF in Drive. Keep it short and celebratory.

Edge cases the agent must handle explicitly:

- No matching deal found: do not create a deal, do not update anything in HubSpot. Still upload the PDF to Drive, then post a Slack message in the same channel flagging the envelope for manual review with the signer info, envelope subject, and the Drive link so a human can attach it to the right deal.

- Multiple plausible open deals: do not pick one. Post a Slack message listing the top candidates (deal name, amount, owner, stage, last activity) and ask a human to confirm before any HubSpot update happens.

- Deal already in a closed stage: skip the update so we do not overwrite a manually closed deal, but still file the PDF in Drive and post a confirmation in Slack.

Configuration the user should be able to set when they install the workflow: the HubSpot pipeline id and the stage id that represents Closed Won, the Google Drive folder id for Signed Contracts, the Slack channel id for win announcements, and an optional Slack channel for manual-review flags (defaults to the same channel).

Additional information

What does this prompt do?
  • Watches Docusign for envelopes that flip to completed, then springs into action automatically.
  • Finds the right HubSpot deal for that signer, moves it to Closed Won, and stamps the close date with the moment the envelope was signed.
  • Saves the signed PDF into a Signed Contracts folder in Google Drive, organized so finance and legal can find it later.
  • Announces the win in your sales Slack channel with the deal name, amount, signers, and a link to the PDF, or flags fuzzy matches for a human to review.
What do I need to use this?
  • A Docusign account with permission to read envelopes and download signed documents.
  • A HubSpot login that can search and update deals in your sales pipeline.
  • A Google Drive folder where signed contracts should be filed.
  • A Slack workspace and the channel where your sales team wants the win announcements.
How can I customize it?
  • Pick which Slack channel gets the announcement, and tweak the wording of the win message.
  • Choose the Google Drive folder for filing signed PDFs, or organize them into subfolders by month, customer, or deal owner.
  • Adjust how strictly the agent matches a signer to a HubSpot deal, and decide what happens when multiple open deals look like a fit.
  • Change the destination deal stage if your pipeline calls it something other than Closed Won.

Frequently asked questions

What if the signer's email does not match the contact on the deal?
The agent looks beyond a strict email match. It checks the signer's email, the company name on the envelope, and any custom fields, then searches HubSpot contacts, companies, and open deals to find the best fit. If nothing matches with confidence, it posts a note in Slack asking a human to pick the right deal.
What happens if there are multiple open deals for that customer?
The agent does not guess. It posts the candidates in Slack with deal names, amounts, and owners so your team can pick the right one to close out.
Will this work with my HubSpot pipeline names and stages?
Yes. You tell the agent which pipeline and which stage represents Closed Won during setup, so it works with custom pipelines.
Where exactly does the signed PDF get saved?
Into the Google Drive folder you choose. You can keep it flat or have the agent create subfolders, for example by customer name or close month, so contracts stay easy to audit.
What if the contract was declined or voided instead of signed?
The workflow only fires when the envelope is fully completed. Declined, voided, or in-progress envelopes are ignored, so nothing in HubSpot changes by accident.

Stop chasing reps to update HubSpot after every signature.

Connect Docusign, HubSpot, Google Drive, and Slack once, and Geni closes the deal, files the contract, and tells the team the moment the ink is dry.