Pikbase Docs
Open console (opens the console)
Esc

Type to search.

Logic and automation

Multilingual documents and email delivery

Render localized templates as HTML or PDF and deliver them through a tenant-registered email provider.

Pikbase provides the tenant runtime for template storage, language selection, rendering, PDF generation, attachment assembly, and email execution. Workspaces can use limited platform email delivery before configuring their own SMTP provider.

Email without workspace SMTP

Without workspace SMTP, only templates included with the workspace can be used for email delivery. Pikbase uses its original versions, not the workspace's edited copies. Saving or pushing changes to an included template does not change emails sent through platform delivery. Custom templates require workspace SMTP.

Configure your provider in Workspace > Settings > SMTP, or use gsb settings smtp, to use your own templates and edits in outgoing email. After setup, check your provider's sender requirements and send a test email. These restrictions concern email delivery, not standalone HTML or PDF generation.

Application content management

The multilingual infrastructure is not limited to documents. Model application content as ordinary entities and mark localized properties as multilingual. When an application calls setGsbLangCode with the user's selected language, the Core client persists that choice and automatically adds it as variation.langCode on subsequent tenant requests. Entity Service returns the matching language variant, so navigation, catalog content, articles, help text, and other CMS-managed content use the same governed data contract as the rest of the application. A caller can override the language for an individual request when needed.

Multilingual templates

A GsbDocTemplate can store one HTML body or multilingual content keyed by language code, including en_us, tr_tr, de_de, fr_fr, es_es, and other supported variants. Template expressions bind entity, workflow, contact, and parameter data at render time. The renderer selects the language variant from the explicit langCode or the active request/workflow variation.

HTML and PDF generation

Use OperationType.CreatePDFDocument (numeric value 12) to render PDF from inline HTML or a stored document template. The operation configuration belongs under docTemplate. See supported workflow operation names and values for the complete enum.

In TypeScript, import OperationType from @gsb-core/workflow-service. JSON payloads use the numeric value, so "operationType": 12 means OperationType.CreatePDFDocument; do not send the enum name as a string.

For inline content, put the HTML in docTemplate.template; this field is HTML, not a template ID:

{
  "orderNumber": 1,
  "operationType": 12,
  "title": "Generate PDF bytes",
  "docTemplate": {
    "template": "<!doctype html><html><body><h1>Receipt</h1></body></html>",
    "byteArrParam": "pdfBytes",
    "usePuppeteer": true
  }
}

A stored template reference belongs at docTemplate.docTemplate.id. Stored template IDs are tenant-specific; replace the sample ID below with the ID of a GsbDocTemplate in the tenant where the function will run.

testWfFunction accepts the supplied function definition and instance as one request object:

import { OperationType } from "@gsb-core/workflow-service";

const operation = {
  orderNumber: 1,
  operationType: OperationType.CreatePDFDocument,
  title: "Generate PDF URL",
  docTemplate: {
    docTemplate: { id: "replace-with-your-tenant-template-id" },
    urlParam: "documentUrl",
  },
};
const operations = JSON.stringify([operation]);
const instance = { entity: {}, prms: {} };

const result = await entityService.testWfFunction({
  function: { name: "GeneratePdf", operations },
  instance,
});

HTML can also come from a workflow parameter (htmlWfParam) or an entity property (htmlEntityParam). Choose an output according to the caller's next step:

Field Result
propertyName Stores the generated file through a target entity property.
urlParam Uploads the PDF and writes its URL to workflow parameters. No target entity is required for URL-only generation.
byteArrParam Writes encoded PDF content to workflow parameters for in-memory use.
fileNameProp Names the entity property whose value supplies the generated filename; it is not a literal filename.

The UI label Upload URL WF Param serializes as docTemplate.urlParam, not an uploadurlwfparam wire field. A raw result may expose generated parameters in top-level prms while instance.prms is empty:

{
  "success": true,
  "status": 0,
  "prms": {
    "documentUrl": "https://storage.example.com/documents/generated.pdf"
  },
  "instance": {
    "entity": {},
    "prms": {}
  }
}

Use the success flag to determine the outcome; status: 0 together with success: true is a successful run.

PDF rendering works with usePuppeteer set to either true or false.

The byteArrParam value is base64-encoded JSON whose string content is the base64 PDF. Decode both layers and validate the result; the value is not a raw byte array.

testWfFunction runs its operations for real: urlParam uploads the generated file to tenant storage, and functions that replace documents can delete earlier files. Test in a non-production workspace and clean up generated files.

Template email

The email function resolves the recipient language, renders the selected document template, translates the subject, and sends HTML or text content. Email operations support To, Cc, Bcc, Reply-To, priority, distinct delivery, and file attachments.

The SMTP-backed sendEmail function uses SmtpService and the runtime-injected nodemailer global. In-memory PDF attachments use the application/pdf content type. The SES library is an alternative configured through tenant-owned _settings.aws.ses. Keep credentials in protected runtime settings as described under provider setup, never in function source.

Queued delivery

The runtime supplies bullmq and ioredis. The groupOperations model schedules sendEmail by its stable function ID. Never serialize runtime or user tokens into queued job payloads. For periodic schedules rather than a queued message, see Recurring jobs.

Generated PDF attachments

In a function or workflow, generate the localized PDF first, then send it with the SMTP-backed sendEmail function as an attachment. The document and message can use the same language context and entity data, keeping invoices, statements, confirmations, and notices consistent. Declarative notification operations (OperationType.SendNotification, numeric value 13) send email without GsbFile attachments, so use sendEmail whenever a message must carry a document.

Register a delivery provider

Configure workspace SMTP with the provider account, sender identity, server, port, TLS, and credentials required by that provider. Credentials remain in protected tenant runtime settings. Pikbase supplies rendering, orchestration, attachment handling, retry-capable SMTP delivery, and execution logs. You and your provider must meet the applicable sender verification, reputation, quota, and transport requirements.

Contract sourcePikbase docs