Custom AI Prompts
Use a custom prompt catalog when your extension needs editable LLM instruction templates in AI Foundation → AI Prompts. Prompt catalogs let your extension ship built-in defaults while allowing editors to create project-specific overrides.
Purpose
AI prompts are feature prompts, not MCP workflow templates. Use them for extension features such as SEO generation, content generation, chat answers, product summaries, or support replies.
AI Foundation provides the backend module and shared storage. Your extension provides the prompt contracts, category metadata, and runtime resolver.
Architecture
PromptContractRegistryYour extension’s PHP source of truth for built-in prompt types, labels, default text, scopes, and required variables.
PromptCatalogProviderInterfaceConnects your prompt contracts to AI Foundation → AI Prompts.
tx_nst3af_ai_promptShared table owned by AI Foundation for editor-created custom prompts.
- Runtime resolver
Your feature code decides which text to use: explicit request text, saved custom prompt, or built-in default.
Implementation steps
Define prompt contracts in your extension.
Implement
NITSAN\NsT3AF\Contract\PromptCatalogProviderInterface.Tag the provider with
t3af.prompt_catalog_provider.Add a runtime resolver that reads custom prompt rows through AI Foundation services.
Use the resolved prompt when calling
AiServiceInterface.Flush caches and verify the category in AI Foundation → AI Prompts.
Prompt contract rules
Use stable
prompt_typevalues, for exampleproduct_summary.Use a unique
category_idprefixed with your extension key.Use
[variable]placeholders for required values.Do not seed built-in prompts into the database. Keep built-ins in PHP.
Minimal contract idea
private const CONTRACTS = [
'product_summary' => [
'scope' => 'catalog',
'label' => 'Product summary',
'defaultText' => 'Summarize [productName] for a [language] product page.',
'requiredVariables' => ['productName', 'language'],
],
];
Service registration
Register prompt providers in your extension.
services:
_defaults:
autowire: true
autoconfigure: true
_instanceof:
NITSAN\NsT3AF\Contract\PromptCatalogProviderInterface:
tags: ['t3af.prompt_catalog_provider']
MyVendor\MyExt\Prompt\:
resource: '../Classes/Prompt/'
Runtime usage
At runtime, resolve prompt text before making the AI request. A common resolution order is:
Explicit prompt text passed by the current request.
Custom prompt selected by title/type from
tx_nst3af_ai_prompt.Built-in default from your contract registry.
Then pass the resolved text to AiServiceInterface with a stable featureKey.
Best practices
Keep category IDs unique across the TYPO3 instance.
Keep prompt types stable after release.
Validate that custom prompt text still contains required variables.
Do not create extension-specific prompt tables unless the implementation requires separate domain data.
Keep prompts focused on one feature workflow.
Verification
Flush TYPO3 caches.
Open AI Foundation → AI Prompts.
Confirm your category card appears.
Open the category and verify built-in prompt rows.
Add a custom prompt and save it.
Trigger your feature and confirm the resolver can use the custom prompt.
Troubleshooting
Category is missing
Confirm the provider is tagged with
t3af.prompt_catalog_provider.Confirm
isAvailable()returnstrue.Flush caches.
Custom prompt is not used
Confirm
extension_key,category_id,scope, andprompt_typematch your resolver query.Confirm the selected prompt title is passed to the feature runtime.