Skip to documentation

Build a custom feedback interface

Send a rating from your own UI and handle failures before showing a success state.

Updated Read as Markdown

Use your own buttons, text field or chatbot rating control when the packaged widget does not fit the experience. Your UI sends a feedback event to https://api.pollenate.dev/collect using an organization collect key.

Submit and confirm success

javascript
async function submitHelpful(isHelpful, comment) {
  const response = await fetch('https://api.pollenate.dev/collect', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-Pollenate-Key': 'YOUR_COLLECT_ONLY_ORGANIZATION_KEY',
    },
    body: JSON.stringify({
      inboxKey: 'YOUR_INBOX_KEY',
      type: 'thumbs',
      score: isHelpful ? 1 : 0,
      comment,
      pageUrl: window.location.origin + window.location.pathname,
      context: { feature: 'documentation', article: 'quickstart' },
    }),
  });
  const result = await response.json().catch(() => ({}));
  if (!response.ok) {
    throw new Error(result.error || 'Feedback could not be saved');
  }
  return result.id;
}

Disable repeat submission while this request is pending. Only show success after the function resolves; fetch itself does not reject merely because the server returned a 400 or 429. Keep the visitor's comment available for retry if the request fails.

Use a score appropriate to the type: thumbs 0/1, stars/CSAT/emoji 1–5, NPS 0–10. For text-only feedback, omit score. Comments have a 2,000-character API limit; enforce a matching UI limit. The collect API reference documents the request and response contract.

Add useful context

Include product fields your team can use to interpret feedback, such as feature, version, route or experiment. The collection route accepts externalUserId but does not persist it as a dedicated feedback-row field. Put an identifier in an appropriate context field when you need it available on readback. Pollenate does not infer your product's plan or experiment automatically. Send only the context needed for the workflow.

Listen to a packaged widget instead

If you only need to react after the standalone widget saves, listen for its event rather than submitting a second copy:

javascript
function onFeedbackSaved(event) {
  console.log('Saved feedback:', event.detail.id);
}
window.addEventListener('pollenate:submit', onFeedbackSaved);
// When your component or page integration is removed:
// window.removeEventListener('pollenate:submit', onFeedbackSaved);

pollenate:impression is the separate impression event. A custom UI does not automatically gain the widget's impression tracking; consult the API documentation if you need a denominator for response-rate analysis.

Keep administrative actions on a server or an appropriately authenticated workspace flow. A public collector should not carry a key that reads responses or manages the organization.