Report Actions

When a workflow displays in-app content, it pauses and waits for the user to do something — click a CTA, dismiss the message, fill in a field. reportAction() is how you tell Treliq what happened so the workflow can continue.

For SDK-rendered content (banners, modals, popovers, tooltips configured in the dashboard), this is automatic — the built-in renderer reports the action when the user interacts. You only need this method when you render content yourself.

Signature

reportAction(
  runId: string,
  actionId: string,
  result: Record<string, unknown>,
): Promise<void>
ArgumentSource
runIdInAppContent.run_id from the item you rendered
actionIdInAppContent.action_id from the same item
resultFree-form payload describing what the user did

Example: custom modal

const items = await treliq.getInAppContent();

for (const item of items) {
  if (item.display_type === 'modal') {
    const choice = await myCustomModal.open(item.content);

    await treliq.reportAction(item.run_id, item.action_id, {
      clicked: choice === 'cta',
      dismissed: choice === 'dismiss',
    });
  }
}

The result payload is stored on the workflow run and is available to subsequent steps for branching:

if action.result.clicked == true → send confirmation email
else                              → send re-engagement email after 3 days

Result conventions

The dashboard defines what shape your workflow expects. Common patterns:

PatternResult
Click vs dismiss{ clicked: true } or { dismissed: true }
Multi-button CTA{ button: 'primary' | 'secondary' | 'tertiary' }
Form submit{ submitted: true, fields: { email: '…' } }
Tooltip walkthrough{ step: 3, completed: false }

Match whatever the workflow author defined. When in doubt, include both a boolean (clicked/dismissed) and the user’s input.

Failure mode

reportAction() returns a promise but the SDK swallows network errors (routing them to onError) so a failed report never breaks your UI. If you must know the result wrote successfully, await the promise and check for thrown errors yourself — but this is rare. Workflows are designed to be resilient to occasional missing reports.

When you don’t need it

  • You let the SDK render in-app content (default). Built-in click/dismiss handlers call reportAction() for you.
  • You only use Treliq for tracking events; no in-app content is configured.