Close Won in HubSpot when a Docusign contract is signed

By General Input

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

Integrations

  • Docusign
  • HubSpot
  • Google Drive
  • Slack

Type

Agentic Task

Categories

  • Sales
  • Operations

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).

Related prompts

Explore more prompts
Call overdue Xero customers with an AI collections agentWin back LiveChat visitors whose chats went unansweredTurn Mailjet email clicks into ranked HubSpot follow-upsiMessage campaign console with pre-flight checks and delivery boardChat quality review board for LiveChat support leadsA searchable RFP answer library your bid team drafts fromSee which target accounts just started advertising on LinkedInAccount health board that puts product usage next to your CRMLook up a customer's full chat history mid conversationLusha prospecting workbench with credit-safe reveals