Helpdesk Widget API reference

Reference for developers and integrators of the Helpdesk Widget: the embed code, everything a page can push to the Widget, the endpoints the Widget uses and the server settings. How-to articles with examples: Data layer, Events and analytics, Teaser and page buttons.

Embed code

<div id="helpdesk_widget"></div>
<script src="https://YOUR-REDMINE/helpdesk_widget/widget.js" async></script>

One request loads the script with the launcher button; the form is loaded when the visitor points at the button. The script is static and cached for 5 minutes, so settings of the Widget tab reach pages within 5 minutes.

Data layer

All page-side configuration goes through window.hdwDataLayer, an array you push objects into at any moment. Pushes merge in order: objects by key, lists and plain values replace, null deletes a key. RedmineHelpdeskWidget.config(obj) is the legacy name for hdwDataLayer.push(obj). Details and examples: Data layer.

Keys

Pass them to hdwDataLayer.push({...}) (or to the older RedmineHelpdeskWidget.config({...}), which is the same). Every attribute is optional. Pushes merge: objects by key, lists and plain values replace, null deletes a key.

Name Type Default value Description
color String '#5f6b76' Accent colour of the launcher button and the form, any CSS colour. Wins over a button-* style class of the settings.
title String Header text setting Header of the form. Replaces the Header text of the Widget settings; accepts basic HTML (b, i, em, strong, br, a, span).
position String bottomRight Corner of the launcher: topLeft, topRight, bottomLeft, bottomRight.
classes String Style classes added to the form and the launcher, space separated, for example 'rounded-large shadow-none'. Added to the classes of the Widget settings.
theme String follows the visitor's system 'light' or 'dark'. Forces a theme.
icon String chat bubble HTML or SVG markup shown inside the launcher button.
user_avatar String Login of a Redmine user: that user's avatar (local or Gravatar) is shown on the launcher.
styles String "" CSS text applied inside the form, for example ':root { --hdw-item-bg: #fff; } changes the background of article titles and suggested questions.
translation Object {} Texts of the form, see Translation attributes.
identify Object {} Prefilled and hidden form fields, see Identify attributes.
articles Array or false list of the settings Sources of articles for this page, for example ['wiki:docs:Delivery']. false hides the Articles tab; an empty or invalid list shows the list of the settings.
suggestedQuestions Array list of the settings Up to 5 questions shown on the Ask AI tab of this page instead of the suggested questions of the settings.
aiSources Array all sources Narrows the AI answers on this page to the listed knowledge sources and articles (lines of the Widget settings).
ask Boolean true false hides the Ask AI tab.
contact Boolean true false hides the Contact us tab and the Create a ticket link under an AI answer.
hide Boolean false true removes the Widget at once, without loading the form. The Widget also disappears when all tabs are hidden.
remember Boolean true false stops saving the visitor's name and email in the browser after a ticket is created.
onEvent Function Receives { name, params } for every Widget event, see Events and analytics.
teaser Object or null One-shot command: shows a card beside the launcher. null removes it. See Teaser and page buttons.
open Object One-shot command: opens an article ({ article: 'source' }) or the Ask AI tab ({ tab: 'ask', question: 'text' }).

Translation attributes

Anything not set keeps the text of your Redmine language.

Name Description
launcherLabel Accessible label of the launcher button, default "Help"
nameLabel Placeholder of the name field, default "Your name"
emailLabel Placeholder of the email field, default "Email address"
subjectLabel Placeholder of the subject field, default "Subject"
descriptionLabel Placeholder of the description field, default "Ticket description"
attachmentLinkLabel Label of the attach file button, default "Attach a file"
createButtonLabel Text of the submit button, default "Create ticket"
createSuccessLabel Title of the message shown after the ticket is created, default "Ticket was created"
createSuccessDescription Text under that title; accepts basic HTML
createErrorLabel Title of the message shown when the ticket cannot be created
teaserClose Accessible label of the Teaser close button, default "Close"

Identify attributes

Name Description
nameValue Name of the visitor. The name field is hidden
emailValue Email of the visitor. The email field is hidden; the contact is found or created by it
subjectValue Subject of the ticket. The subject field is hidden
projectIdentifier Identifier of the project (for example 'support'), one of the Available projects of the Widget settings. An unknown value is ignored
projectValue Name of the project, one of the Available projects. The project field is hidden
trackerValue Name of the tracker of that project. The tracker field is hidden
issueCategory Category of the ticket, by name
customFieldValues Object of custom field name and value, for example { 'Source page': location.href, 'UTM campaign': 'spring' }. Only fields checked in Available custom fields of the Widget settings count. Send an empty string, not null, to keep a field hidden without a value

Every prefilled field is hidden from the visitor. Name and email reach the form by a browser message, the other values travel in the form address (so they reach server logs: no personal data there). Everything the page sends is a hint: see Rules the server applies.

Example

<div id="helpdesk_widget"></div>
<script src="https://YOUR-REDMINE/helpdesk_widget/widget.js" async></script>

<script>
  window.hdwDataLayer = window.hdwDataLayer || [];
  hdwDataLayer.push({
    color: '#af1287',
    position: 'bottomLeft',
    title: 'How can we help you?',
    translation: {
      nameLabel: 'Please enter your name here',
      emailLabel: 'Please put your email here',
      descriptionLabel: 'What question do you have?',
      createButtonLabel: 'Ask question',
      createSuccessLabel: 'Your question was successfully created',
      createSuccessDescription: 'Thank you for your question!',
      createErrorLabel: 'Something went wrong :('
    },
    identify: {
      nameValue: 'User',
      emailValue: 'user@example.com',
      subjectValue: 'This is my question',
      trackerValue: 'Question',
      projectIdentifier: 'support',
      customFieldValues: { 'Source page': location.href }
    }
  });
</script>

Commands and events

  • teaser and open are one-shot commands, and data-hdw-article / data-hdw-ask attributes call the same ones: Teaser and page buttons.
  • onEvent receives { name, params } for every Widget event: the full list is in Events and analytics.

Rules the server applies

  • A ticket is always created by the anonymous user. The contact comes from the email, as for incoming mail. A user id or email sent by the page never makes that user the author.
  • The project must be one of the Widget's available projects (by id or identifier) and the tracker one of its trackers, otherwise the request is refused.
  • From the ticket only the subject, the description and the custom fields enabled in the Widget settings are read. Other custom fields are dropped.
  • A missing name or email is a validation error. An attachment has a size limit and the form has a honeypot field.
  • A tab hidden by the page (articles: false, ask: false, contact: false) is only an interface choice: the server keeps its own checks.

Endpoints the Widget uses

These serve the Widget itself; build on the data layer, not on them.

Endpoint Purpose
GET /helpdesk_widget/widget.js the loader script, cached for 5 minutes
GET /helpdesk_widget/frame the form, rendered on the server
POST /helpdesk_widget/ask start an AI answer; returns the question token
GET /helpdesk_widget/ask/TOKEN/events progress and text of the answer; the token alone authorizes
DELETE /helpdesk_widget/ask/TOKEN cancel the answer
GET /helpdesk_widget/article an article of the list, by source
GET /helpdesk_widget/article/FILENAME an image of an article
GET /helpdesk_widget/articles/search search over the articles

To create a ticket from your own code without the form, see REST API Create ticket.

Server settings of Ask AI

Set in configuration.yml, section helpdesk, ask. The defaults work without it; Redmine reads the file at start.

Key Default Meaning
max_length 1000 characters in a question
per_ip_per_hour 30 questions per visitor address in the last hour
total_per_hour 300 questions from all visitors in the last hour
tokens_per_hour 500000 input plus output tokens of finished answers in the last hour
retention_days not set days to keep run data, IP address, name and email of a question
helpdesk:
  ask:
    per_ip_per_hour: 20
    retention_days: 90
  • A visitor has one active answer at a time; a new question replaces the previous one.
  • When a limit is reached new visitors see only the ticket form; an open panel says that the limit is reached.
  • Limits are counted per visitor address (an IPv6 address by its /64 prefix). Behind a proxy they follow the Rails trusted_proxies setting; a misconfigured proxy makes the limit spoofable.
  • With retention_days set, older questions keep text, answer and vote, while the AI runs are deleted and the IP address, name and email are cleared. Server request logs are not cleared. Not set: nothing is purged.

Related articles

Was this article helpful? Yes  No
2008 from 2058 found this helpful