22 lines
1.1 KiB
Markdown
22 lines
1.1 KiB
Markdown
# 5. Wait, async, and completed hooks
|
|
|
|
Timestamping is not always instant. Middleware publishes `verae.zapier.jobs.watch`; a poller waits on the chain; then `verae.zapier.jobs.events` fires. Zapier never sees those subjects.
|
|
|
|
## Choose a pattern
|
|
|
|
| Pattern | Use when |
|
|
|---------|----------|
|
|
| **Wait** | The next Zap step needs the certificate now (Slack message, PDF receipt). |
|
|
| **Async + Find Job Status** | You stored `jobId` and will poll later. |
|
|
| **Timestamp Completed trigger** | You want a second Zap to run when the seal exists (REST Hook). |
|
|
|
|
If **Wait** returns `status: pending`, the chain or NATS event did not finish inside `WAIT_TIMEOUT_MS`. Pair async creates with the **Timestamp Completed** trigger instead of raising the timeout blindly.
|
|
|
|
## Trigger setup
|
|
|
|
1. New Zap → Verae Time → **Timestamp Completed**.
|
|
2. Zapier registers a REST Hook URL with middleware (`/zapier/v1/webhooks/subscribe`).
|
|
3. When `jobs.events` says `timestamp.completed`, middleware HTTPS POSTs that URL.
|
|
4. Turning the Zap off unsubscribes the hook.
|
|
|
|
The hook payload is the same completed-job JSON as wait (seal receipt, optional attached metadata).
|