Rek.ai 

Extension key

rekai

Package name

pluswerk/rekai

Version

1.0.0

Language

en

Author

Pluswerk AG

License

This extension is published under the GNU General Public License v3.0 or later.

Copyright

Pluswerk AG

Description

Integrates rek.ai into TYPO3. Provides automatic script embedding via middleware, optional search autocomplete, and two content elements: Rek.ai Recommendations and Rek.ai Q&A.

Keywords

rekai, rek.ai, recommendations, personalization, autocomplete, qna, content element

This extension integrates rek.ai — an AI-driven personalization service — into TYPO3. It provides:

  • Automatic injection of the rek.ai client script on all frontend pages
  • Optional search autocomplete for any input field
  • Content element Rek.ai Recommendations to display personalized page recommendations
  • Content element Rek.ai Q&A to display context-aware questions and answers

Introduction 

Rek.ai is an AI-powered personalization service that delivers page recommendations, Q&A widgets, and search autocomplete to website visitors. All personalization logic runs in the visitor's browser via a small JavaScript client — no personal data is sent from your TYPO3 server to rek.ai.

This extension handles the TYPO3 integration:

  • It injects the rek.ai script tag into every frontend page via a PSR-15 middleware.
  • It provides two content elements that output the required HTML placeholder markup.
  • It exposes all relevant rek.ai configuration options through the TYPO3 extension settings UI.

Architecture overview 

The extension does not call rek.ai APIs from PHP. Instead, TYPO3 outputs HTML <div> elements with data-* attributes, and the rek.ai JavaScript client reads those attributes at runtime to render personalized content.

Feature overview 

  • Middleware-based script embedding in frontend responses
  • Consent mode support (data-useconsent attribute)
  • Optional autocomplete initialization for a configurable CSS selector
  • Content element Rek.ai Recommendations (rekai_recommendations)
  • Content element Rek.ai Q&A (rekai_qna)
  • Test mode with project ID and secret key for sandbox environments

Compatibility 

  • TYPO3: 12.4 LTS, 13.4 LTS, 14.x
  • PHP: 8.1 or higher

Installation 

Requirements 

  • TYPO3 12.4 LTS, 13.4 LTS, or 14.x
  • PHP 8.1 or higher
  • A rek.ai account with a project and script URL

Install via Composer 

composer require pluswerk/rekai
Copied!

Include TypoScript 

The extension ships TypoScript that must be included in your site template.

  1. Open Site Management > Templates
  2. Edit the root template of your site
  3. In Includes, add Rek.ai to the list of included static templates

Alternatively, if your setup uses Site Sets (TYPO3 13+), include the extension TypoScript via your site's config.yaml:

dependencies:
  - pluswerk/rekai
Copied!

Activate the extension 

In non-Composer setups, activate the extension manually:

  1. Open Admin Tools > Extensions
  2. Find rekai and activate it
  3. Flush all caches

Configure the extension 

After installation, open Admin Tools > Settings > Extension Configuration > rekai and at minimum:

  • Set Enabled to 1
  • Enter the Embed Code URL from your rek.ai dashboard

See Configuration for all available settings.

Configuration 

Extension settings 

All global settings are managed in:

Admin Tools > Settings > Extension Configuration > rekai

General 

Setting Type Description
isEnabled boolean Master switch. Disabling this prevents the rek.ai script from being injected on any page. Default: 0.
embedCode string HTTPS URL to the rek.ai client script (e.g. https://cdn.rek.ai/YOUR_PROJECT/s.js). Must start with https://.
consentMode boolean Adds data-useconsent="true" to the script tag, enabling rek.ai's built-in consent handling. Default: 0.

Autocomplete 

Setting Type Description
autocompleteMode select disabled — no autocomplete. auto — rek.ai initializes autocomplete automatically. manual — you call rekai_autocomplete() yourself. Default: disabled.
autocompleteSelector string CSS selector targeting the search input field, e.g. #tx-solr-search-q. Required when mode is auto or manual.
autocompleteNrOfHits integer Number of autocomplete suggestions shown (1–100). Default: 10.
autocompleteNavigateOnClick boolean If enabled, the browser navigates to the result URL when a suggestion is clicked. Default: 0.
autocompleteUseCurrentLang boolean Passes the current TYPO3 page language to rek.ai autocomplete for language-filtered suggestions. Default: 0.

Advanced / Test mode 

Setting Type Description
testMode boolean Enables test mode. In this mode no visitor data is tracked, and window.rek_blocksaveview = true is injected. Also active for logged-in backend users regardless of this setting. Default: 0.
useMockData boolean Replaces live rek.ai data with synthetic mock data for local development. Default: 0.
projectId string Your rek.ai project ID. Required in test mode.
secretKey password Your rek.ai API secret key. Required in test mode.

Content element FlexForm settings 

Each content element exposes additional settings through a FlexForm panel visible in the backend. See Editor Guide for field descriptions.

Validation behaviour 

If the extension is enabled but embedCode is not a valid HTTPS URL, the rek.ai script is silently not injected. No error is thrown.

Editor Guide 

Adding a content element 

Both rek.ai content elements are available in the new content element wizard under the rek.ai group:

  • Rek.ai Recommendations — displays personalized page recommendations
  • Rek.ai Q&A — displays context-aware questions and answers

Standard TYPO3 header fields (header, subheader, header layout) are available on each element and rendered by your site template in the standard TYPO3 way.

Rek.ai Recommendations 

Tab: General 

Field Description
Number of Hits How many recommendations rek.ai should return. Range: 1–100. Default: 10.
Render Style Visual layout of the recommendations widget: list, pills, or advanced (card grid). Default: list.
Show Image If enabled, rek.ai includes a page thumbnail in each recommendation.
Show Ingress If enabled, rek.ai includes a short teaser text in each recommendation.
Columns Number of columns for the advanced grid style. Range: 1–6. Default: 2.

Tab: Filter 

Field Description
Subtree Comma-separated relative URL paths. Limits recommendations to pages under these paths (e.g. /news/,/blog/).
Exclude Tree Comma-separated relative URL paths to exclude from recommendations.
Allowed Languages Comma-separated ISO language codes (e.g. de,en). Limits recommendations to pages in these languages.
Tags Comma-separated rek.ai tags for additional content filtering.

Rek.ai Q&A 

Tab: General 

Field Description
Number of Hits How many Q&A items rek.ai should return. Range: 1–100. Default: 10.
Current page questions only If enabled, only Q&As indexed for the current page are shown (sets data-currentpagequestions).

Tab: Filter 

Same filter fields as Rek.ai Recommendations (Subtree, Exclude Tree, Allowed Languages, Tags).

Developer Notes 

Architecture overview 

The extension has three independent parts:

  1. Middleware — injects the rek.ai script tag into every frontend response
  2. Controllers — produce <div data-*> placeholder markup for the content elements
  3. TypoScript / Fluid — integrates the content elements into lib.contentElement

Middleware 

Pluswerk\Rekai\Middleware\RekaiScriptMiddleware runs in the frontend middleware stack (after prepare-tsfe-rendering, before output-compression) and uses TYPO3's AssetCollector to inject:

  • the external rek.ai script from embedCode
  • an optional data-useconsent="true" attribute when consent mode is active
  • an optional inline autocomplete bootstrap script
  • window.rek_blocksaveview = true; for backend users and in test mode

Controllers 

RecommendationsController::showAction() and QnaController::showAction() both inherit from AbstractRekaiController. They build a <div> element with the rek.ai data-* attributes derived from the content element's FlexForm settings and the global extension configuration, then assign it to the Fluid template as {divHtml}.

The controllers do not perform any HTTP calls to rek.ai. All data fetching happens in the visitor's browser via the injected JavaScript.

Templates 

Content element integration uses the lib.contentElement FLUIDTEMPLATE mechanism. Two templates are registered under a dedicated template root path:

  • Resources/Private/Templates/Content/RekaiRecommendations.fluid.html
  • Resources/Private/Templates/Content/RekaiQna.fluid.html

These templates use <f:layout name="Default"/> and define only a Main section, delegating header rendering to the standard TYPO3 Default layout from EXT:fluid_styled_content.

The plugin action templates (consumed by Extbase) are separate:

  • Resources/Private/Templates/Recommendations/Show.html
  • Resources/Private/Templates/Qna/Show.html

These output only {divHtml} — the raw <div> placeholder.

TypoScript 

Configuration/TypoScript/setup.typoscript adds the content template root path to lib.contentElement:

lib.contentElement {
    templateRootPaths.20 = EXT:rekai/Resources/Private/Templates/Content/
}
Copied!

The templateName mapping (RekaiRecommendations / RekaiQna) is set in ext_localconf.php via ExtensionManagementUtility::addTypoScript() with position defaultContentRendering, ensuring it runs after ExtensionUtility::configurePlugin() and overrides the generic default.

Extension configuration 

Pluswerk\Rekai\Configuration\ExtensionConfigurationService wraps TYPO3\CMS\Core\Configuration\ExtensionConfiguration::get() and provides typed accessor methods for all settings. It is injected via constructor injection (autowired).

Dependency injection 

All classes use TYPO3's standard DI container (Configuration/Services.yaml with autowire: true and autoconfigure: true). No manual service wiring is required.

Testing 

Unit tests cover ExtensionConfigurationService and RekaiScriptMiddleware:

vendor/bin/phpunit --configuration vendor/pluswerk/rekai/phpunit.xml
Copied!

Known Problems 

No output in frontend 

  • Verify that Enabled is set to 1 in Admin Tools > Settings > Extension Configuration > rekai.
  • Verify that Embed Code URL is a valid https:// URL.
  • Flush all TYPO3 caches.
  • Check the browser developer tools network tab to confirm the rek.ai script is loaded without errors.

Header not rendered 

The extension registers its content elements using TYPO3's standard content element API and the --palette--;;headers palette. Header rendering is handled by your site template's Default layout (from EXT:fluid_styled_content). If your sitepackage overrides lib.contentElement without including the standard layout root path (EXT:fluid_styled_content/Resources/Private/Layouts/), the header may not appear.

Autocomplete not working 

  • Verify that autocompleteMode is set to auto or manual.
  • Verify that autocompleteSelector matches an input element that exists on the page.
  • Confirm the rek.ai script is loaded successfully (no console errors).

TypoScript not loaded 

If the content elements render no output at all, the extension TypoScript may not be included in your site template. See Installation for how to add the static template or Site Set dependency.

Content element not available in wizard 

Flush the TYPO3 backend cache after installation. If the problem persists, verify the extension is active under Admin Tools > Extensions.