Neidio i’r prif gynnwys

Dilyniannu Oes Dogfen a Derbynnydd gyda Tanysgrifiadau

Defnyddiwch danysgrifiadau GraphQL i dderbyn diweddariadau oes amser-real megis:

  • creu dogfen
  • creu PDF terfynol
  • gwrthod dogfen
  • anfon e-bost derbynnydd
  • ymweliad derbynnydd
  • cwblhau derbynnydd
  • gwrthod derbynnydd
  • agor e-bost derbynnydd

Am gontract pacio cyffredinol, gweler:

Bwydlenni a Chategorïau

Darperir digwyddiadau oes fel arfer ar:

  • subscribeGroupFeed

Efallai y bydd rhai digwyddiadau oes hefyd yn cael eu lledaenu i:

  • subscribeUserFeed

Categorïau:

  • documentLifecycle
  • recipientLifecycle

Enwau Digwyddiadau

Oes dogfen

  • documentCreated
  • documentFinalPdfCreated
  • documentRejected

Oes derbynnydd

  • recipientSentEmail
  • recipientVisiting
  • recipientCompleted
  • recipientRejected
  • recipientEmailOpened

Siâp y Payload

Oes dogfen

{
"version": "1.0",
"eventId": "evt...",
"timestamp": "2026-04-24T10:38:36.822Z",
"level": "INFO",
"event": "documentCreated",
"category": "documentLifecycle",
"groupId": "grp...",
"userId": "usr...",
"requestId": null,
"batchId": null,
"error": null,
"data": {
"id": "doc...",
"documentName": "Example document"
}
}

Oes derbynnydd

{
"version": "1.0",
"eventId": "evt...",
"timestamp": "2026-04-24T10:38:36.822Z",
"level": "INFO",
"event": "recipientVisiting",
"category": "recipientLifecycle",
"groupId": "grp...",
"userId": "usr...",
"requestId": null,
"batchId": null,
"error": null,
"data": {
"id": "rec...",
"documentId": "doc...",
"documentName": "Example document",
"firstName": "Ada",
"lastName": "Lovelace"
}
}

Gweithred Tanysgrifio

subscription SubscribeGroupFeed($groupId: String!) {
subscribeGroupFeed(groupId: $groupId) {
groupId
data
}
}

Enghraifft JavaScript

const parseEnvelope = (payload) => {
const raw = payload?.data;
if (!raw) return null;
return typeof raw === 'string' ? JSON.parse(raw) : raw;
};

const handleGroupFeed = ({ data }) => {
const wrapper = data?.subscribeGroupFeed;
const event = parseEnvelope(wrapper);

if (event?.category === 'documentLifecycle') {
switch (event.event) {
case 'documentCreated':
case 'documentFinalPdfCreated':
case 'documentRejected':
console.log('document lifecycle event', event.event, event.data.id);
break;
default:
break;
}
}

if (event?.category === 'recipientLifecycle') {
switch (event.event) {
case 'recipientSentEmail':
case 'recipientVisiting':
case 'recipientCompleted':
case 'recipientRejected':
case 'recipientEmailOpened':
console.log('recipient lifecycle event', event.event, event.data.id);
break;
default:
break;
}
}
};

Pryd i'w Ddefnyddio

Mae hyn yn ddefnyddiol pan hoffech:

  • diweddaru rhestr o ddogfennau neu ffrwd gweithgaredd mewn amser real
  • dangos digwyddiadau ymgysylltu derbynnydd heb arolygu
  • ymateb ar unwaith pan fydd PDF terfynol yn barod
  • gyrru hysbysiadau llif gwaith mewn dangosfwrdd