Close won in Dynamics 365 and invoice when a contract is signed

When a contract is fully signed, we close the matching deal as won in Dynamics 365, raise the invoice, and announce the win in Microsoft Teams.

Agentic Task
DocusignMicrosoft Dynamics 365Microsoft TeamsSalesFinanceNotifications & AlertsData Sync
PromptCreate

Watch Docusign for envelopes that reach completed status, meaning every signer has finished signing. When one completes, close the loop between the signed contract and our Microsoft Dynamics 365 records, then announce the win in Microsoft Teams.

Start by reading the signed agreement. Use Docusign Get Envelope for the envelope status, subject and completion date, List Recipients for everyone who signed along with their names, emails, roles and the dates they signed, and Get Envelope Form Data to pull the values that were actually typed into the document's form fields. From that form data extract the customer or account name, the total contract value, and the billing contact if the document captures one. Treat the form field values as the source of truth for the contract amount rather than anything in the envelope subject line.

Then find the deal. Use Dynamics 365 Query Records against the opportunity table, filtering on the customer name from the envelope and restricting to open opportunities only, so deals that are already closed are never touched. Account names rarely match exactly, so compare sensibly across naming variants: legal suffixes such as Inc, Ltd, LLC or GmbH, ampersands versus the word and, punctuation differences, and trading names versus registered names. It is fine to query the account table first if that helps resolve the customer to the right account before looking at their opportunities.

This next part is the important safeguard. Only proceed if the envelope matches exactly one open opportunity. If it matches none, or if it matches more than one and you cannot be confident which is correct, then close nothing and create nothing, making no changes whatsoever in Dynamics 365. Instead post a Microsoft Teams Create Channel Message to the revenue channel saying a contract was signed, naming the customer, the contract value and the signers, listing any candidate opportunities you found with their names and estimated values, and asking someone to confirm which deal it belongs to. Apply the same caution if the contract value from the envelope looks clearly wrong against the opportunity's estimated value, for example different by an order of magnitude, since that usually means the wrong deal was matched or a value was mistyped. In that case stop and ask in Teams rather than closing the deal.

When there is exactly one confident match, do three things in Dynamics 365. Use Win Opportunity to close it as won, using the actual contract value from the envelope as the closing revenue rather than the original estimate. Use Create Invoice to raise an invoice for the agreed amount against that customer, using the billing contact from the signed document. Use Create Record to log a note against the opportunity for audit purposes, holding the Docusign envelope id, the full list of signers with their names, emails and signing dates, and the contract value taken from the form fields.

Finally, post a Microsoft Teams Create Channel Message to the revenue channel announcing the win. Include the customer, the contract value, who signed, and the date the contract was completed. Write it as a short, readable announcement that a sales leader would actually want to read, not a dump of raw fields.

A couple of edge cases to handle. If the matched opportunity is already closed as won, skip the writes so the same contract is never processed twice, and say so in the Teams message. If one of the Dynamics steps fails after the opportunity has already been closed as won, state that clearly in the Teams message so nobody assumes the invoice and the audit note were created.

Example output

Contract signed: Northwind Traders Value: $184,000 Signed by: Dana Whitfield (VP Operations, Northwind Traders) and Marcus Lee (Account Executive) Completed: 7 August 2026 Closed as won in Dynamics 365 at $184,000 and an invoice was raised for the same amount to the billing contact on the agreement. An audit note with the signer list has been saved against the deal.

What does this prompt do?

  • Watches for contracts that everyone has finished signing, then reads the signed document to pull out the customer, the agreed contract value, and the people who signed it.
  • Finds the matching open deal in Microsoft Dynamics 365, closes it as won at the real contract value, raises an invoice for the agreed amount, and saves an audit note against the deal.
  • Announces the win in a Microsoft Teams channel with the customer, contract value, signers and close date.
  • If the signed contract cannot be matched to exactly one open deal, it changes nothing at all and asks your team in Teams to confirm which deal it belongs to.

What do I need to use this?

  • A DocuSign account where your contracts get signed.
  • A Microsoft Dynamics 365 account with access to your deals, invoices and customer records.
  • A Microsoft Teams channel where wins should be announced.
  • Contracts that capture the customer name and contract value in fillable fields, so those values can be read reliably from the signed copy.

How can I customize it?

  • Swap Microsoft Teams for Slack if your revenue team lives there instead.
  • Change which channel gets the announcement and what it includes, for example adding the deal owner or the contract start date.
  • Skip the invoice step if your finance team raises invoices separately, or have it log the note only.

FAQs

What happens if the signed contract does not match a deal?
Nothing is changed. The workflow deliberately stops before touching anything, and instead posts a message in Microsoft Teams with the customer, contract value and signers, along with any close matches it found, so a person can confirm which deal it belongs to.
Could it close the wrong deal if we have several open deals with the same customer?
No. It only closes a deal when the contract matches exactly one open deal. If more than one open deal could plausibly be the right one, it closes nothing and asks in Teams instead.
How does it know what the contract is worth?
It reads the values that were actually typed into the signed document rather than guessing from the file name or subject line, and it sanity checks that amount against the deal's expected value before closing anything.
Can it post to Slack instead of Microsoft Teams?
Yes. Slack works as a direct substitute for the announcement, and you can point it at whichever channel your revenue team uses.
Does the invoice get created in Dynamics 365 or in our accounting software?
The invoice is created in Microsoft Dynamics 365 against the customer and billing contact from the signed contract. If you invoice from a separate finance system, you can drop that step.

Related templates

Send Workable offer letters for signature automatically

The moment a candidate reaches your offer stage in Workable, the offer letter goes out for signature, gets logged, and the recruiting team is notified.

Workable
Docusign
Google Sheets
+1
Deterministic Code
Daily SonarCloud quality gate status board in Teams

Every weekday morning, post every failing SonarCloud project into Microsoft Teams, so builds that have been red for a week stop slipping past your team.

SonarCloud
Microsoft Teams
Deterministic Code
Nudge Dynamics 365 deal owners about stale pipeline in Slack

Every weekday morning, an agent reviews your open Dynamics 365 pipeline and privately DMs each rep only the deals that need attention today.

Microsoft Dynamics 365
Slack
Agentic Task
Update Dynamics 365 deals automatically after every Gong call

After every recorded sales call, an agent updates the right deal in Dynamics 365 and posts a Slack recap of exactly what changed.

Gong
Microsoft Dynamics 365
Slack
Agentic Task
File contact sales form leads into Dynamics 365 without duplicates

Every contact sales form submission lands in Dynamics 365 as a clean lead, updating the record you already have instead of creating a second one.

Google Forms
Microsoft Dynamics 365
Slack
Deterministic Code
Turn every signed contract into a searchable renewal register

Every contract you sign gets read, logged, and dated automatically, so you always know the last day to give notice before it renews.

Docusign
Mistral AI
Google Sheets
+1
Agentic Task

Stop retyping signed contracts into your CRM.

Let every completed contract close its own deal, raise its invoice, and tell the whole team.