> For the complete documentation index, see [llms.txt](https://doc.duaer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.duaer.com/organizations/write-back.md).

# Send decisions on Duaer cards back to the system each case is in

When people approve or reject on a Duaer card, the decision goes back to Feishu approval, DingTalk approval, Weaver e-cology, Kingdee Cloud Galaxy or your own system; when a case is handled there, its card closes by itself.
## Decide in Duaer, and the decision goes back to the system it came from

When cases come from systems such as Feishu approval, an OA or an ERP, the Approve or Reject a person picks on a Duaer card can go back to that system, so nobody clicks it again there.

Duaer never writes into the other system's database: only through that system's API, or a webhook you run. Write-back is off until the owner or an admin turns it on, card rule by card rule.

## A case handled in its own system closes its card

Nothing to set up. Each time a card rule runs, a card closes when its case's status is no longer open, it is no longer overdue, or it has another owner, and Decided in the employee portal says Handled in its own system. With another owner, the new owner gets a new card.

A case deleted from the Duaer cases table leaves its card alone, so writing the cases table again does not close everyone's cards at once.

## Set up write-back

1. The owner or an admin opens Duaer Settings › Write-back (under Connections).
2. Under Targets, select Add a webhook, Add Feishu approval, Add DingTalk approval, Add Weaver e-cology or Add Kingdee Cloud Galaxy, fill it in, and select Save.
3. Under Card rules, choose where a rule writes back to and which options, then select Save. Save shows once something changed.
4. When a target needs members' accounts in its system, fill them in under Member accounts.

## Feishu approval

On cards from a Feishu approval source, the case id is the approval instance code. When the person decides, Duaer uses the organization's Feishu app to find their waiting task in that approval and approves or rejects it as them, with the comment written on the card; Feishu records them as the approver.

- Connect Feishu in knowledge sources first; without it, adding Feishu approval says Feishu is not connected.
- The Feishu app needs read and write access to approvals, requested under the app's permissions on the Feishu Open Platform.
- In the card rule, set each option to Approve, Reject or No write-back; an option set to No write-back decides in Duaer only.
- Members' Feishu accounts: members linked in Feishu are used as they are. For others, the first time they decide, Duaer looks them up in Feishu by their Duaer email and keeps what it finds. For anyone still not matched, under Member accounts choose Email or Mobile number and enter what Feishu has for them, and Duaer finds and keeps the account; or choose Account ID and enter the open_id. Someone without a Feishu account is stopped when they decide and asked to have an admin add it.
- When the approval already ended in Feishu, the person has no waiting task in it, or Feishu returns an error, the card is back in the queue with the reason.

## DingTalk approval

The card's case id must be the DingTalk approval instance id. When the person decides, Duaer uses the organization's DingTalk app to find their running task in that approval and approves or rejects it as them, with the comment written on the card as the remark; or it only adds the comment to the approval.

- Connect DingTalk in knowledge sources first; without it, adding DingTalk approval says DingTalk is not connected.
- The DingTalk app needs read and write access to approvals, requested under the app's permissions on the DingTalk Open Platform.
- In the card rule, set each option to Approve, Reject, Comment or No write-back. Comment only adds a comment and leaves the approval as it is; nothing is sent when the card has no comment.
- Members' DingTalk accounts: members the DingTalk directory read matched by email are used as they are. For others, under Member accounts choose Mobile number and enter their DingTalk mobile number, and Duaer finds and keeps their userId; or choose Account ID and enter it. What an admin sets wins. DingTalk cannot look people up by email. Someone without a DingTalk account is stopped when they decide, and Duaer does not call DingTalk.
- When the approval already ended in DingTalk, the person has no running task in it, or DingTalk refuses, the card is back in the queue with the reason.

## Weaver e-cology

On cards from a Weaver e-cology source, the case id is the request id. When the person decides, Duaer submits or returns that request through e-cology 9's API as them, with the comment written on the card as the sign-off note.

- Ask Weaver to issue an appid for Duaer (a row in ECOLOGY_BIZ_EC) and to open /api/ec/dev/auth/regist and /api/ec/dev/auth/applytoken in unchecksessionurl in weaver_session_filter.properties.
- Select Add Weaver e-cology, fill in the e-cology address and the appid, and save; Duaer registers with e-cology then and says why if it cannot.
- In the card rule, set each option to Approve (submit), Reject (return) or No write-back.
- Under Member accounts, fill in each person's e-cology user ID. Someone without one is stopped when they decide, and Duaer does not call e-cology.
- When e-cology does not take it, for example no permission or the request is no longer with that person, the card is back in the queue with e-cology's reason. When an attempt got no answer and the retry is refused, the card says the first attempt may have gone through; check the request in e-cology.

## Kingdee Cloud Galaxy

The card's case id is the bill number in the chosen form; on cards from a Kingdee Cloud Galaxy source, that is the purchase or sales order number. When the person decides, Duaer logs in through the credential's third-party app as their Kingdee user name and submits, audits or unaudits the bill, so Kingdee records them.

- Add a Kingdee Cloud Galaxy credential under Credentials first; its third-party app must be allowed to log in as other users.
- Select Add Kingdee Cloud Galaxy, pick the credential and fill in the form ID (PUR_PurchaseOrder by default; SAL_SaleOrder for sales orders).
- In the card rule, set each option to Submit, Audit, Unaudit or No write-back. These operations take no comment; a comment written on the card stays in Duaer.
- Under Member accounts, fill in each person's Kingdee user name. Someone without one is stopped when they decide, and Duaer does not call Kingdee.
- Duaer reads the bill's status first: a bill already in the wanted status counts as synced and is not run again. When the status does not allow the action (such as auditing a bill not yet submitted), Kingdee refuses, or the login fails, the card is back in the queue with the reason.

## Webhook

To reach another system, or hand decisions to your own middleware, use a webhook: Duaer POSTs each decision to the Address you set.

- The body is JSON: event (card.decided; ping for a test), key, attempt, decidedAt, card (projectId, id, ruleId, caseId the case id, title, link), decision (choice, label, comment, values), person (email, account).
- Signature: the X-Duaer-Signature header is sha256= followed by the hex HMAC SHA-256 of the raw body with the Signing secret; check it first. The secret has 16 characters or more, is not shown again once saved, and is kept when left empty while editing.
- Every attempt for the same card has the same key (also in the X-Duaer-Delivery header), so a repeat can be ignored.
- A 2xx answer is synced; a 4xx is refused, and the card comes back with the reason, taken from message or error in a JSON answer; a 5xx, 408, 429, or no answer within 10 seconds is tried again.
- System of the accounts is optional; when set (for example weaverApproval), each delivery carries the person's account in that system, and someone without one is stopped when they decide.
- Test sends one request with event ping, and the page shows Test passed or why it failed.

## The other system first, then Duaer

After a person decides a write-back card, it says Sending to the target. Only once that system takes it does Duaer change the case's status and carry out what follows; when it does not, the card is back in the queue and the case is unchanged.

With no answer, it is sent again after 1 minute and after 5 minutes, 3 attempts in all, and the card comes back if all fail.
## Questions

### Can cards a workflow sends write back?

Write-back is set per card rule. On a card a workflow sends, the workflow gets the option and the comment once the person decides; add a node after it that calls the other system.

### What happens to a card whose write-back failed?

It is back in the person's queue with the reason. Once the reason is fixed (for example approval access for the Feishu app, or the member's account filled in), the person decides again.

### Does Duaer write into our ERP database?

No. Duaer reads some systems straight from their database, but writes back only through the system's API or your webhook, never into its database.

## Related

- [Give employees their own Duaer employee portal](https://doc.duaer.com/organizations/employee-portal.md)
- [Give people tasks in Duaer with the tasks table](https://doc.duaer.com/build/duaer-tasks.md)
- [Process findings and SOP conformance in Duaer](https://doc.duaer.com/build/process-findings.md)
- [Add a process source in Duaer](https://doc.duaer.com/build/process-sources.md)

