(Disclosure: I’m connected to thirds.ai.)
Drafted with AI help.
A common question here is how to send a generated PDF by email from inside a workflow, or how to get a QR code label onto a record. This walks through both with a workflow node plugin, Workflow: Render. It is MIT licensed, and the code is on GitHub as thirdsai/nocobase-plugin-workflow-render. Rendering runs on thirds.ai, so you need an account and an API key there.
1. Install
Download the .tgz from the GitHub release, then:
yarn pm add /path/to/plugin-workflow-render-0.1.0.tgz
yarn pm enable @thirdsai/plugin-workflow-render
Put the key in the server environment (for example .env), then restart NocoBase:
THIRDS_API_KEY=your-key
The key stays in the environment. It is not saved in the database or in the workflow.
2. Invoice PDF that is saved and emailed
Collection invoices with number, customer, email, amount, description and an attachment field pdf.
- New workflow, trigger After record added on
invoices. - Add the node Render PDF or image:
- Collection
invoices, Record ID{{$context.data.id}}, attachment fieldpdf - Source HTML. Choose the Invoice (PDF) starter.
- QR code
paywith valuehttps://example.com/pay/{{$context.data.number}} - Format PDF, A4. File name
invoice-{{$context.data.number}}
- Collection
- Add a Mailer node after it. Set To to
{{$context.data.email}}, and under Attachments pick the render node’s result. The node returns the saved file record, which is what the Mailer expects.
Add an invoice: the PDF appears in the pdf field and the same file goes out by email.
3. QR label PNG
Collection assets with name, code and an attachment field label. Use the trigger After record added, then Render PDF or image with the QR label (PNG) starter, format PNG at 800 by 400, QR code code set to {{$context.data.code}}, saved to label.
Template tips
The HTML can mix NocoBase variables ({{$context.data.customer}}, filled in by NocoBase) with template tags ({{ record.customer }}, filled in from the record the node sends). The node also sends title, a fields list for looping, and qr:
<h1>{{ title }}</h1>
<table>
{% for f in fields %}<tr><th>{{ f.label }}</th><td>{{ f.value }}</td></tr>{% endfor %}
</table>
<img src="{{ qr.pay | safe }}">
- A missing value stops the render, so give optional fields a default:
{{ record.note | default('') }}. - QR images need
| safeinsrc.
Questions and bug reports are welcome in this thread or on the GitHub repo.