Overview

Receive support email through a Dynamics 365 Customer Service queue, create cases with an automatic record rule and send reviewed Voiceflow answers as case-linked Dataverse email activities. This cloud walkthrough uses tracking tokens for reply correlation.

The existing Dynamics 365 Sales integration supplies reusable Dataverse authentication, not an incoming Customer Service channel. This manual chooses cloud queue/case polling; on-premises rules and Microsoft’s own autonomous email agents are different approaches.

Before you begin

Prepare the agent, platform administrator and relay operator.

Use an existing support agent with approved public Knowledge. The agent owner publishes the intended Environment; the help desk administrator owns email routing and assignment; a backend developer operates the relay.

This supervised example answers public support questions. Email addresses and help desk records do not authorize access to private customer data. Keep AUTO_SEND=false: APIs do not consistently expose raw automatic-response headers, so a person reviews every outbound message and its recipients.

Prepare the relay

Install the supplied implementation and durable review queue.

1

Configure the executable service

Extract the relay bundle, enter email-relay and run with Node 24.14.1:

Use the generated value for IDENTITY_SECRET. Set VF_PROJECT_ID, VF_API_KEY, VF_ENVIRONMENT, a fixed UTC ACCEPT_AFTER just before the pilot and ALLOW_SENDERS to your test inbox. Keep AUTO_SEND=false and POLL_SECONDS=60. The provider steps below supply the remaining fields.

The bundle’s helpdesk-adapters.mjs implements the exact provider calls; helpdesk.mjs checks ownership and input, and the shared worker stores message identities, sessions and cached replies. Read its HELPDESKS.md for file/operation mapping.

2

Keep one worker and a narrow pilot

Use one process/database for this provider, address, automation owner and scope. The relay scans the selected pilot work and paginates histories; it does not use a webhook or expiring event subscription. API/OAuth credentials still require renewal or rotation. Its 300-page cap fails visibly rather than silently truncating a large scan.

This is a small supervised deployment with no distributed lease or bounded work queue. Monitor quota, disk and oldest pending work; add incremental ingestion and capacity controls before a high-volume rollout.

Connect receiving and replies

Configure the native email channel and its API permissions.

1

Connect the queue mailbox and case rule

Create/select the support email queue in Customer Service. Approve its mailbox, configure server-side synchronization for incoming/outgoing mail and run Test & Enable Mailbox until both paths succeed. Verify the From identity and mailbox authorization with your Exchange/mail administrator.

In the Copilot Service admin center, open Case settings → Automatic record creation and update rules. Create an Email rule monitoring the pilot queue, add a condition for your test senders and create a Case linked to the incoming email. Activate the rule and configure its case assignment to a dedicated automation user or owner team. The cloud rule documentation owns these steps. Confirm a new external email appears as an incoming Email activity regarding the Case; a queue item alone is insufficient.

2

Authorize the Dataverse application user

Use the existing Dataverse authentication instructions for Entra registration, application-user creation and client-credentials access. This workload needs its own security role: read the pilot Cases, Email and Activity Party records; read/use the queue; create Email/Activity Party, append to the Case/queue and execute Send Email. Grant only the necessary record scope. Sales Lead/Task permissions do not supply Customer Service email permissions.

In the environment’s System Settings → Email tab, set Allow messages with unresolved email recipients to be sent to Yes for this address-only recipient implementation. An administrator must accept that organization setting before using this example. Microsoft’s recipient documentation explains the default restriction.

Set PROVIDER=dynamics-365, HD_ORIGIN=https://YOUR_ORG.crm.dynamics.com, HD_CLIENT_ID and HD_CLIENT_SECRET. Replace the example’s MS_TENANT=common with the environment’s Microsoft Entra directory tenant GUID. Leave HD_TOKEN empty. Set HD_OWNER_ID to the actual automation Case owner GUID and HD_SCOPE_ID to the sending/receiving queue GUID. Queue membership and Case ownership are different; use the Case’s _ownerid_value, not the queue ID, for the owner. Set all three mailbox/sender fields to the queue email address.

3

Create a case-linked email and send it

The relay uses Dataverse v9.2 to list open Cases with that owner, then reads their Email activities and Activity Parties. Only incoming emails with the configured queue as a To party become input. It converts HTML descriptions to plain text and holds files. Outgoing emails cannot start a customer turn.

For a reviewed answer it requests GetTrackingTokenEmail, creates an outgoing Email regarding the same Case, supplies a queue From party and customer To address, then calls the bound Microsoft.Dynamics.CRM.SendEmail action with IssueSend=true and the tracking token. It does not write read-only conversationindex or inreplyto or promise an RFC In-Reply-To header. Dataverse correlation depends on your email tracking settings; test both Case continuity and the customer’s inbox grouping.

To inspect the native IDs, first fill this provider’s credentials, then run the supplied read-only helper in a private terminal:

Replace any PILOT_…_ID with the native ID from a ticket/conversation you can open. The helper permits ID discovery before owner/scope fields are filled; it only performs GET requests plus any required OAuth token exchange. Its output can contain customer data. Copy the fields identified above, then run the scoped check below.

The supplied adapter builds this reply payload after approval; replaceable IDs come from the native incoming record, not from the language model:

Run the persistent worker

Verify read access, then start processing without a public webhook.

1

Check the native route without sending

After filling .env, run:

Expect your test ticket/conversation with the correct owner, open=true, scoped=true and eligible=true. This command may obtain/cache an OAuth token but sends no Voiceflow turns or customer replies. Also confirm the unresolved-recipient setting above, tracking tokens and both mailbox sync tests; the read-only API check cannot prove those settings or outgoing delivery. Resolve access/routing problems before starting the worker.

2

Start locally, then host the same state

In another terminal, curl -f http://127.0.0.1:8080/health should report running. No public /inbound endpoint is enabled for help desks. Polling uses outbound HTTPS and stored server credentials; there is no incoming webhook secret or subscription to configure.

For a persistent Linux host, install Docker/Compose, copy the bundle and protected .env, set DB_PATH=/app/data/relay.sqlite, and run docker compose up -d --build. The supplied service has a persistent volume and restart policy; port 8080 is bound to host loopback. Keep it private. If you obtained a local OAuth grant, stop the local worker and copy its complete stopped database into the host volume before starting; never run both copies. The bundle README gives the exact database copy commands.

Keep tickets and sessions aligned

Use native ownership, message identity and the actual customer sender.

Case GUID plus actual sender address scopes the Voiceflow session. The outgoing activity’s regarding link and tracking token provide case correlation. A customer’s edited/removed token, new Case or changed sender can intentionally create a new session; the relay does not merge those histories by subject.

Reassign to a person before replying manually. The recheck is not a universal lock: keep competing humans/automations outside this assignment. Resolve old held jobs before returning work to automation.

For additions during review, show identifies helpdesk.priorJobs and the hold reason. Inspect those cached answers and all new questions, discard stale work, then write one reconciled reply for the newest held job; the agent does not replay earlier messages.

Files stay in the help desk and are never fetched or forwarded. Check original quoted/inline content; the quote heuristic is limited. Outgoing/agent messages cannot start self-reply loops. Manual review also screens external auto-responses whose raw headers the API omits.

Test the complete conversation

Prove receiving, agent execution and actual email delivery separately.

1

Receive, review and deliver the first answer

From the permitted external inbox, email the support address. Confirm the native ticket/conversation and its automation assignment, then inspect the queue and Voiceflow transcript:

Replace JOB_ID with the actual ID from list. Approve only after checking the question, cached answer, original sender/recipients and support identity; the next worker pass sends it. For review-input, have a person inspect the original and write a reply with the shared review workflow. Expected result: one runtime answer, one reviewed native reply and an email in the test customer’s inbox.

Inspect the outbound Email activity, queue mailbox send status and customer inbox. Then reply with the tracking token retained and verify the same Case. An accepted SendEmail action can still be pending or fail during server-side synchronization.

2

Test continuation, takeover and recovery

Reply in-thread with a follow-up requiring earlier context. Expect the same native conversation and sender-scoped runtime session. Send a separate new support request and expect a new session. Repeat polling and restart the worker; expect no duplicate answer for an already processed native message.

While a reply awaits approval, reassign the ticket to a person, then approve the cached job in this controlled test. Expect ignored and no email. Also test a human reply, two consecutive customer messages, an attachment, an auto-response and a changed Reply-To where supported. Reconcile/discard held work before assigning the conversation back. Finally exercise a controlled API rejection and interrupted send, then use recovery below.

The email never becomes eligible work

Check the native email channel before the agent.

Confirm a real incoming email record, open status, exact automation owner, scope/address and pilot cutoff. The read-only check reports these separately. Check sender allowlisting and provider API permissions; a healthy process cannot prove the support mailbox is receiving. A private note, outgoing email, archived ticket or unrelated channel should not run the agent.

The answer is held or becomes stale

Inspect the durable state and original conversation.

review-input needs an operator-written answer after inspecting the original; review has a cached candidate. ignored with a ticket-change explanation means the ownership/content guard prevented a stale reply. Do not force it through by resetting the database. Discard old held work after the human takes responsibility. Check the released Environment and runtime transcript for uncertain-turn.

The reply was accepted but no email arrived

Reconcile provider delivery before any retry.

Use show to find the persisted providerSend.id and inspect that exact Email activity. A timeout between create and SendEmail can leave a draft; do not create another activity blindly. If it is unsent, resolve/send that existing activity in Dynamics and discard or mark the relay job after confirming the outcome. Check mailbox approval, unresolved-recipient policy, security-role privileges and correlation settings.

Keep a timed-out write in uncertain-send until native history proves whether it was accepted. Never rerun the agent to recreate a cached answer. A 429 backs off using Retry-After; the sample never retries a write automatically.

Release and maintain the connection

Keep review, assignment and durable recovery in place.

1

Release the reviewed support route

Publish the reviewed Voiceflow Environment, deploy one worker and repeat the entire customer test through the production support address. Keep AUTO_SEND=false; the example enforces it for help desks. Widen ALLOW_SENDERS only with approved public-support scope, abuse controls and staffed review. Record API/seat access, email delivery and takeover acceptance in your deployment record.

Changing provider, address, owner/scope, project, Environment, cutoff or identity secret requires draining/resolving old work and a new database. Credential rotation alone does not. Stop the worker before copying/backing up SQLite, preserve its WAL if present, encrypt backups and set retention for help desk content, transcripts and local records.

2

Recover without replaying unknown writes

uncertain-turn may include completed tool side effects: inspect the transcript before using restart JOB_ID --reviewed-side-effects. For uncertain-send, inspect native history and delivery. If already sent, use mark-sent JOB_ID; if confirmed never accepted, use retry-send JOB_ID --confirmed-not-sent to retry the cached answer. Run these through node --env-file=.env cli.mjs …; ownership is checked again before any send. The Dynamics multi-step send requires its activity-specific recovery above.

Monitor poll errors, API quota, failed delivery, disk and held-job age. Rotate/revoke credentials with the provider administrator and retest. For rollback, route/assign work to human support, resolve queued jobs, stop the relay and then revoke its credentials. Receiving remains in the help desk during relay outages; reconcile the native backlog against durable jobs before resuming.

Use the up and down arrow keys to select a result, Enter to open it, and Escape to close the search.