AI Email Template Generator for Magento 2
- Compatibility
- 2.4.9, 2.4.8, 2.4.7, 2.4.6, 2.4.5, 2.4.4, 2.4.3, 2.4.2, 2.4.1, 2.4.0, 2.3.7, 2.3.6, 2.3.5, 2.3.4
Description / AI Email Template Generator for Magento 2
MAGENTO 2 · EMAIL TEMPLATES · AI · MAGENTO QUEUE
Prepare a new email version in the native Magento editor.
Kowal AI Email Template Generator
Add a prompt, reference design, and graphic assets to a saved template. Run generation in the background, review the result, and apply it to the template name, subject, content, and styles.
JSON and validation · Job history · Control over applying results
HOW IT WORKS IN PRACTICE
01 · Describe the expected change
Add a prompt, reference, and brand assets.
02 · The queue processes the request
The consumer runs the job and saves the result or error.
03 · Review and apply the design
Verify the variables, appearance, and message content.
What does your store gain?
Explore the module features, use cases, and settings.
Meet the module
AI Email Theme Generator extends Magento 2 email template management with AI-assisted generation. The module adds a practical process for improving native Magento transactional templates directly from the admin panel, without replacing the standard email template system.
Administrators can generate, rebuild, improve, or expand existing Magento email templates using ChatGPT via the OpenAI API. The generated result is returned as structured data and can be saved to native Magento fields:
- Template Name
- Template Subject
- Template Content
- Template Styles
The process is controlled, auditable, and asynchronous. Each AI request is handled by the Magento queue and tracked as a separate job with information about status, history, errors, request payload, response payload, and the generated result.
Business value
Magento transactional emails are an important customer touchpoint, but their default appearance is usually very generic and requires manual HTML/CSS work to match the brand. AI Email Theme Generator reduces the time needed to prepare better email templates while keeping the result within Magento native infrastructure.
The module works well for:
- refreshing default Magento transactional emails,
- creating email layouts consistent with brand identity,
- improving message subjects and content,
- matching templates to a provided graphic design,
- preserving Magento variables and directives,
- working in a repeatable process that can be reviewed and controlled.
AI generation in the native Email Templates editor
The module extends the standard Magento admin interface:
Marketing > Communications > Email Templates
A saved template receives additional AI fields directly in the standard Magento email template editor. The administrator can enter a prompt, add an optional reference design, prepare graphic assets, and request generation using ChatGPT.
Structured AI response
The AI result is expected as JSON and mapped to native Magento fields:
{ 'template_name': 'New Order Confirmation - Guest', 'template_subject': 'Your order confirmation', 'template_content': '', 'template_styles': '/* CSS */', 'warnings': [], 'change_summary': 'Updated layout and improved copy.', 'variables_used': ['order.increment_id', 'store.frontend_name']}
This makes the result predictable and easier to validate before saving.
Asynchronous processing
Generation is not performed while the admin page is loading. The module creates a queue job and processes it in the background using Magento Message Queue.
This prevents long waits in the admin panel and gives the team a clear view of every generation request.
Job history and error handling
Generation jobs are available in:
Marketing > Communications > AI Email Generation Jobs
Each job shows:
- current status,
- number of attempts,
- model used,
- related template,
- prompt,
- generated result,
- request and response payload,
- warnings,
- error message,
- status history.
Failed jobs can be retried, pending jobs can be canceled, and completed results can be applied manually if automatic result saving is disabled.
Optional reference design
Administrators can add a reference file, such as an image, HTML, or text file. The file is attached to the AI context and can be used to generate a template aligned with the selected visual concept.
Structured email graphic assets
The native email template editor can also store AI assets assigned to a specific template:
- logo,
- header image,
- dynamic banner list,
- dynamic icon list.
Each asset can have a label, alt text, target URL, and sort order. Banner and icon rows can be added dynamically in the form.
During generation, the module passes an assets section to AI with public frontend URLs grouped by purpose. This lets ChatGPT know which image is the logo, which one belongs to the header, which files are banners, and which are icons.
This approach provides a more predictable email layout than passing a single general reference image.
Configurable technical prompt
The module includes a global technical prompt used with every generation request. The prompt contains fixed technical rules, such as:
- preserve Magento directives,
- do not invent unavailable variables,
- do not add JavaScript,
- maintain compatibility with email clients,
- return only a JSON response.
This separates technical instructions from the business prompt written for an individual template.
Installation only via Composer
The module is prepared as a Composer package for Magento:
kowal/module-ai-email-theme-generator
It is intended to be installed as a vendor package, not manually copied to app/code.
Translation-ready
The module is implemented in English, and all visible text is prepared for the Magento i18n mechanism through translation helpers or translatable labels and XML comments.
Transactional email redesign
AI can be used to modernize default Magento emails, such as:
- new order confirmation,
- shipment confirmation,
- invoice email,
- credit memo email,
- customer account emails,
- password reset.
Brand alignment
The administrator can provide a prompt and reference design so the generated template matches the store communication tone, color palette, typography expectations, and layout style.
Developer workflow support
Developers can use the module to generate an initial template version, then review the result, validate Magento directives, and refine the final HTML/CSS.
Controlled experimentation
Because every request is saved as a job, the team can compare prompts, models, results, warnings, and errors without losing history.
Security and control
AI Email Theme Generator is designed to support administrators and developers, not bypass validation or the Magento template review process.
The module supports:
- encrypted API key storage,
- configurable automatic result application,
- queue-based processing,
- job status tracking,
- retry and cancel actions,
- single and bulk job deletion,
- validation of required AI response fields,
- blocking
scripttags in generated content, - structured graphic assets with frontend URLs,
- optional storage of request and response payloads.
In production environments, it is recommended to disable automatic result application until the team verifies the quality of generated templates for its prompts and use cases.
Summary
AI Email Theme Generator brings AI-assisted email template generation to the Magento 2 admin panel while preserving the native Email Templates workflow. The module helps improve transactional emails faster, keeps the process auditable through queued jobs, and gives developers control over prompts, response format, and how the result is applied.
A consumer is required to run the job
The configuration is located in Stores → Configuration → Services → AI Email Theme Generator. Provide the API key, select the model, and set timeouts, retry settings, and the result application policy.
Jobs are executed by the consumer kowal.ai_email.generate.consumer. In production, ensure it runs through the process manager you use. Saving a request to the queue alone does not mean generation has been completed.
Manual review is the default policy
The module and automatic result application are disabled by default. The validator checks required response fields, their types, a non-empty name, subject, and content, and blocks the script tag.
This does not replace checking directives, variable availability, and rendering in email clients. Test the template on the correct message type before assigning it to production sending.
References, graphics, and history
The default reference file limit is 5 MiB, and the allowed extensions are png, jpg, jpeg, webp, html, htm, and txt. Logo, header, banner, and icon assets are passed with their public URLs.
The request sends the content and context to the AI service. Payload retention is configurable; the history lets you review the result, warnings, and errors. The module generates templates; it does not run campaigns or marketing email sending.
Installation via Composer
Package kowal/module-ai-email-theme-generator, module Kowal_AiEmailThemeGenerator. After configuring access to the Kowal repository, install the package, enable the module, update Magento, and clear the cache. In production, include compilation and static content deployment according to your store process.
From configuration to result
1. Describe the expected change
Add a prompt, reference, and brand assets.
2. The queue processes the request
The consumer runs the job and saves the result or error.
3. Review and apply the design
Verify the variables, appearance, and message content.
Order confirmation refresh
Load the native template, add your logo, and provide instructions for the brand style. AI prepares a proposal that preserves the indicated directives.
Before use, review the preview, real order data, and rendering in email clients. You can apply the result manually.
Streamline transactional template preparation
Want to adapt the module to your store? Ask about implementing Kowal AI Email Template Generator and discuss configuration or required extensions.
More Information
| Purchase information | View the module DEMOusername: emails |
|---|---|
| Theme compatibility | Luma / Blank, KOWAL |
Module Installation Instructions
Installation and configuration guide
1. Requirements
The module is intended for Magento 2 and a Composer-managed installation.
Required:
- a Magento 2 project managed by Composer,
- a PHP version compatible with the Magento installation in use,
- access to Magento CLI,
- OpenAI API key,
- a running Magento Message Queue consumer process.
Module package:
kowal/module-ai-email-theme-generatorMagento module name:
Kowal_AiEmailThemeGenerator2. Installation
Add the Composer repository:
Composer repository access credentials, the customer email address and license token, will be sent to you by email after purchase. They are also available in the customer panel after signing in at kowal.store. Replace TWOJ_EMAIL_KLIENTA with your account email address and TWOJ_TOKEN with the received token. Run the commands in the Magento root directory.
composer config repositories.kowal composer https://repo.kowal.storeConfigure access credentials for the Kowal Composer repository:
composer config http-basic.repo.kowal.store 'TWOJ_EMAIL_KLIENTA' 'TWOJ_TOKEN'Install the module:
composer require kowal/module-ai-email-theme-generatorEnable the module:
bin/magento module:enable Kowal_AiEmailThemeGeneratorRun the Magento update:
bin/magento setup:upgradeClear the cache:
bin/magento cache:flushFor production mode, run the standard deployment commands used in your project, for example:
bin/magento setup:di:compile
bin/magento setup:static-content:deploy
bin/magento cache:flush3. Queue Consumer
AI generation is processed asynchronously by Magento Message Queue.
Start the consumer manually:
bin/magento queue:consumers:start kowal.ai_email.generate.consumerIn production environments, configure the consumer under supervisor, systemd, or another process manager used by your hosting.
The module creates jobs in the admin panel, but the AI request will not be processed until the consumer is running.
4. Administrator permissions
The module adds ACL resources:
Kowal_AiEmailThemeGenerator::rootKowal_AiEmailThemeGenerator::jobsKowal_AiEmailThemeGenerator::generateKowal_AiEmailThemeGenerator::retryKowal_AiEmailThemeGenerator::cancelKowal_AiEmailThemeGenerator::applyKowal_AiEmailThemeGenerator::deleteKowal_AiEmailThemeGenerator::settingsTo allow an administrator to use the module, assign the appropriate resources in:
System > Permissions > User RolesFor full access, allow the main AI Email Generation resource and all child resources.
5. Configuration location
Go to:
Stores > Configuration > AI Email Generation > AI Email Theme GeneratorThe configuration section contains the group:
General Settings6. Configuration fields
Enabled
Type: Yes/No
Default: No
Enables or disables module features.
When set to No:
- the module should not create AI generation jobs,
- the generation action is blocked,
- the administrator should configure the module first.
Set Yes only after preparing the API key and starting the queue consumer.
API Provider
Type: Select
Default: OpenAI
Defines the AI provider used by the module.
The current implementation supports:
OpenAIThis field exists so that additional providers can be added in the future without changing the administrator workflow.
OpenAI API Key
Type: hidden/encrypted field
Stores the OpenAI API key used for generation.
The value is encrypted by Magento using:
Magento\Config\Model\Config\Backend\EncryptedImportant:
- do not place the API key directly in code,
- do not commit environment keys,
- restrict access to this field through ACL,
- use a key with permissions appropriate for the project.
OpenAI Model
Type: Select
Defines the OpenAI model used for generation.
Example:
gpt-4.1The list is fetched dynamically from the OpenAI Models API using the configured API key. The module filters the response to GPT model identifiers and caches the list for a short time to avoid calling the API every time the configuration is opened.
If the API key has not been saved yet, the field will show a fallback option and ask the administrator to save the key.
If the OpenAI API is temporarily unavailable, the field keeps the currently configured model where possible.
Use a model that supports the required input type:
- text generation for prompts and template content,
- a model that supports images if graphic reference designs are used.
The selected model affects result quality, response time, and cost.
Request Timeout
Type: Number
Example default value:
120Maximum time in seconds allowed for the request to the OpenAI API.
Recommended values:
60for short text generation,120or more for complex HTML/CSS generation,- higher values only when the infrastructure allows longer queue jobs.
The timeout applies to background processing, not the admin form request.
Maximum Retries
Type: Number
Example default value:
2Defines how many times the consumer can automatically retry a failed generation job.
Retries are useful for temporary errors, such as:
- API timeout,
- temporary provider error,
- rate limit,
- network issue.
Persistent errors, such as incorrect configuration or an invalid AI response, should be checked in the job details.
Technical Prompt
Type: Textarea
This prompt is applied to every generation request. It should contain technical rules that must always be preserved.
Example:
You are an assistant generating Magento 2 email templates.Return only JSON that matches the provided schema.Keep Magento directives valid.Do not invent Magento variables.Do not add JavaScript.Put CSS in template_styles unless inline styles are required for email compatibility.Preserve required variables and add warnings when a requested change is risky.When assets are provided, use only the URLs from the assets section, preserve alt text, apply target links to clickable images, use banners and icons according to their sort_order, and do not invent additional image URLs.Use this field for stable instructions, such as:
- preserving Magento directives,
- maintaining required variables,
- avoiding JavaScript,
- returning only JSON,
- writing HTML compatible with email clients,
- using CSS in the correct result field.
Do not use this field for one-time creative instructions. Use AI Prompt in the template form for that.
Default User Prompt
Type: Textarea
This prompt is shown by default in the AI section of the email template editor.
Example:
Improve this Magento email template while keeping all required Magento variables and directives valid.The administrator can change it before creating a generation job.
Use this field to set a practical default instruction for typical generation tasks.
Allowed Design File Types
Type: Text
Example default value:
png,jpg,jpeg,webp,html,htm,txtComma-separated list of allowed file extensions for the optional reference design.
Supported examples:
pngjpgjpegwebphtmlhtmtxt
In production, use the most restrictive list possible. Do not allow file types that are not needed in the process.
Maximum Design File Size
Type: Number
Example default value:
5242880Maximum reference file size in bytes.
Examples:
1048576= 1 MB5242880= 5 MB10485760= 10 MB
Large files increase the payload size and may slow down generation or exceed provider limits.
Automatically Apply Result
Type: Yes/No
Default: No
Defines whether a valid AI result should immediately overwrite the native Magento template fields.
When set to Yes, the consumer saves the generated result to:
- Template Name
- Template Subject
- Template Content
- Template Styles
When set to No, the result is stored in the job and the administrator can review it before applying it manually.
Recommended production setting:
NoManual approval is safer because the AI result may be technically valid but still require brand, legal, or layout review.
Keep Request and Response Payloads
Type: Yes/No
Default: Yes
Defines whether the module stores full request and response payloads in the job record.
When enabled, job details can show:
- template snapshot sent to AI,
- available variables,
- prompts,
- reference design metadata,
- AI response.
This is useful for debugging and auditing.
In production environments, review privacy requirements before enabling this option. The module should not send real customer data to AI, but payloads may still contain business-sensitive template content.
Retention Days
Type: Number
Example default value:
30Defines how long old jobs should be retained.
This value documents the target retention policy. The project can use it to implement scheduled cleanup according to operational requirements.
7. Example: generating the New Order Confirmation for Guest template
This example describes the full process of generating an improved Magento email template for:
New Order Confirmation for GuestStep 1: Configure the module
Go to:
Stores > Configuration > AI Email Generation > AI Email Theme GeneratorSet:
Enabled = YesAPI Provider = OpenAIOpenAI API Key = <your OpenAI API key>OpenAI Model = gpt-4.1Request Timeout = 120Maximum Retries = 2Automatically Apply Result = NoKeep Request and Response Payloads = YesSave the configuration and clear the cache if Magento asks you to.
Step 2: Start the queue consumer
Run:
bin/magento queue:consumers:start kowal.ai_email.generate.consumerDuring testing, the process should run continuously.
Step 3: Create a native Magento template
Go to:
Marketing > Communications > Email TemplatesClick:
Add New TemplateIn the Template field, select:
New Order Confirmation for GuestClick:
Load TemplateMagento will populate the native fields:
- Template Subject
- Template Content
- Template Styles
Set the template name, for example:
New Order Confirmation for Guest - AI DraftSave the template.
The AI generation process requires a saved template because the job must have a persistent template_id.
Step 4: Complete the AI Prompt
After saving, open the template again if needed. The standard Magento email template editor contains an AI Email Generation section.
In the AI Prompt field, enter a business instruction, for example:
Create a modern, clean transactional email for a premium fashion store.Keep all Magento order variables and directives valid.Improve the subject line and make the content easier to scan.Add a clear order summary section, shipping information section, and customer support footer.Use neutral colors, simple spacing, and email-client-safe HTML.Meaning of this field:
- describes the expected business result,
- applies only to the specific generation job,
- may include instructions about the brand, communication tone, layout, or content,
- should not contain API data or real customer data.
Step 5: Optionally add Design Reference
Use Design Reference if the generated email should follow a specific visual direction.
Example files:
order-email-reference.pngbrand-email-layout.webpemail-layout.htmldesign-notes.txt
Meaning of this field:
- gives AI additional visual or structural context,
- helps match the template to a graphic design,
- is optional,
- must meet extension and file size limits.
If no reference design is added, AI will use only the template content, variables, technical prompt, and user prompt.
Step 6: Optionally add Error Screenshot
Use Error Screenshot if you want to show AI the current rendering, layout, or template validation issue.
Examples:
- a screenshot of a misaligned header,
- a screenshot of a banner issue,
- an email preview with incorrect spacing,
- a screenshot from an email client showing a responsiveness issue,
- a screenshot of an error message from a testing tool.
This field is passed to AI as a separate JSON section:
{ 'error_screenshot': { 'type': 'image', 'filename': 'email-rendering-error.png', 'mime_type': 'image/png', 'content_base64': '...', 'purpose': 'current_error_context', 'description': 'Screenshot showing current rendering, layout, visual, or validation errors. Use it to understand what should be fixed. This is not a design reference.' }}Meaning of this field:
- shows AI the current error to fix,
- is not a graphic design or target appearance reference,
- helps AI understand what is currently not working,
- should be used together with a clear problem description in
AI Prompt.
Example prompt:
Use the attached error screenshot only to understand the current rendering issue.Fix the spacing problem visible in the screenshot while preserving Magento variables.Do not treat the screenshot as the target design.Step 7: Add structured AI Assets
The editor contains an AI Assets area. These assets are saved with the Magento template and passed to AI as grouped frontend media URLs.
Available asset groups:
| Field | Meaning |
|---|---|
| Logo | Brand logo used in the email header or footer. |
| Header Image | Main graphic for the top part of the email. |
| Banners | Dynamic list of promotional or informational banners. |
| Icons | Dynamic list of small graphic elements, such as benefits or service icons. |
Each asset can include:
| Field | Meaning |
|---|---|
| File | Graphic file uploaded to Magento media storage. |
| Label | Internal name that helps AI understand the asset purpose. |
| Alt Text | Text used in the image alt attribute. |
| Target URL | Link used when the image should be clickable. |
| Sort Order | Display priority for banners and icons. |
For banners and icons, click:
Add BannerAdd IconThe module saves uploaded assets in Magento media storage and passes public frontend URLs to AI in the structure:
{ 'assets': { 'logo': { 'label': 'Brand logo', 'url': 'https://example.com/media/ai_email_theme_generator/template_12/logo/logo.png', 'alt': 'Brand logo', 'link': 'https://example.com/', 'sort_order': 0 }, 'header_image': { 'label': 'Spring campaign header', 'url': 'https://example.com/media/ai_email_theme_generator/template_12/header/header.jpg', 'alt': 'Spring collection', 'link': 'https://example.com/spring', 'sort_order': 0 }, 'banners': [ { 'label': 'Main promotion', 'url': 'https://example.com/media/ai_email_theme_generator/template_12/banner/banner.jpg', 'alt': '20% off new collection', 'link': 'https://example.com/new', 'sort_order': 10 } ], 'icons': [ { 'label': 'Free delivery', 'url': 'https://example.com/media/ai_email_theme_generator/template_12/icon/delivery.png', 'alt': 'Free delivery', 'link': 'https://example.com/delivery', 'sort_order': 10 } ] }}Refer to these groups directly in prompts. Example:
Use the uploaded logo as the main brand mark.Use the header image at the top of the email.Place banners below the order summary using their sort order.Use icons in a benefits row and link each icon to its target URL.Always preserve alt text.Step 8: Select generation after saving
Enable:
Generate with AI after savingMeaning of this field:
- Magento first saves the template using the standard native save action,
- after a successful save, the module creates an AI generation job,
- the uploaded reference design is attached to the job,
- the job is processed asynchronously by the queue consumer.
If the checkbox is not selected, saving the template works exactly like the standard Magento save action, and no AI job is created.
Step 9: Save the template
Click the standard Magento button:
Save TemplateAfter the template is saved, the module creates a generation job.
At this point:
- the native template save is complete,
- the job status starts as
pending, - the queue consumer processes the job in the background.
Step 10: Check the job
Go to:
Marketing > Communications > AI Email Generation JobsOpen the created job.
Key fields:
| Field | Meaning |
|---|---|
| Status | Current processing status. |
| Template ID | ID of the native Magento email template. |
| Template Name | Template name saved when the job was created. |
| Model | OpenAI model used for generation. |
| Attempts | Number of processing attempts. |
| Prompt | User prompt submitted from the template form. |
| Request Payload | JSON sent to AI if payload storage is enabled. |
| Response Payload | JSON returned by AI if payload storage is enabled. |
| Generated Result | Parsed result ready to apply. |
| Assets | Public frontend URLs and metadata for the logo, header, banners, and icons. |
| Error Screenshot | Screenshot with current errors, passed to AI as fix context. |
| Warnings | AI warnings about risky or incomplete requirements. |
| Error Message | Error cause when generation fails. |
| Status History | History of job status changes. |
Typical statuses:
| Status | Meaning |
|---|---|
pending | The job has been created and is waiting for the consumer. |
processing | The consumer is currently processing the job. |
retry_scheduled | The previous attempt failed and a retry has been scheduled. |
completed | AI returned a valid result. |
failed | The job failed after all attempts or validation failed. |
cancelled | The administrator canceled the job. |
Step 11: Apply the result
If Automatically Apply Result = No, the result is not automatically saved to the Magento template.
Check:
- Template Name
- Template Subject
- Template Content
- Template Styles
- Warnings
- Request Payload
- Response Payload
If the result is correct, click:
Apply ResultThe module will save the generated values to the native Magento template fields.
Step 12: Verify the native email template
Return to:
Marketing > Communications > Email TemplatesOpen the template and check:
- Template Name has been updated,
- Template Subject has been updated,
- Template Content contains the expected HTML and Magento directives,
- Template Styles contains the expected CSS,
- required Magento variables have not been removed.
Send a test message or run a test order flow according to the project standard QA process.
Step 13: Send another correction to AI
After applying the result with Apply Result, the current template version is saved in native Magento fields. This means the next AI request will be based on this version, not on the original template.
You can refine the same template multiple times:
- Apply the AI result using
Apply Result. - Open the template again in
Marketing > Communications > Email Templates. - Enter a new prompt describing the specific correction.
- If the issue is visual, add
Error Screenshot. - Select
Generate with AI after saving. - Save the template.
- Review the new job and apply the result if it is correct.
For subsequent corrections, treat AI Prompt as a description of the change to the current version. It is best to indicate:
- what is currently wrong,
- what result should be achieved,
- which elements AI should not change,
- whether the attached
Error Screenshotshows a rendering error, visual layout, responsiveness issue, or validation message.
Example prompt for a subsequent correction:
Use the current saved template as the base.Fix the spacing issue visible in the attached error screenshot.Keep the current header layout, all Magento variables, and the existing Template Styles structure.Do not redesign the whole email.This workflow is useful when the first version is close to the expected result but needs detail refinements, such as spacing, responsiveness, banner visibility, logo position, or button style.
You can repeat this cycle many times. Each new job creates a separate history entry, so you can return to previous prompts, payloads, and AI responses to check which instruction led to a specific change.
8. Meaning of AI payload fields
The module sends a structured payload to AI. The most important sections are:
template
Contains the current state of the Magento template:
- template ID,
- template name,
- subject,
- content,
- styles,
- original template code.
AI uses this section as the base material for generation.
Important: if the AI result was previously applied using Apply Result, the template section already contains that updated version. This allows the next generation to work as a correction to the current template.
variables
Contains Magento variables and directives detected in the template.
AI should preserve these values and should not invent unsupported variables.
prompts
Contains:
technical- global technical prompt from the configuration,user- prompt entered in the template editor.
The technical prompt protects Magento-specific structure. The user prompt describes the expected result for one template.
design_reference
Contains optional metadata and content of the uploaded reference design.
The section is empty when no reference file has been uploaded.
error_screenshot
Contains an optional screenshot showing current rendering, layout, visual, or validation errors.
This section has a purpose and description so AI knows that the file is used to understand the problem, not as a target design reference.
The section is empty when no screenshot has been uploaded.
For subsequent corrections, it is worth using error_screenshot together with a precise prompt that states what should be fixed and what should not be changed. This allows AI to fix a specific issue without rebuilding the entire template.
Example: after applying the first AI result, the administrator notices that in Gmail a banner overlaps the order summary section. In the next request, they attach a screenshot of that view and enter a prompt asking only to fix the spacing and banner width. The payload still contains the current Template Content and Template Styles, so AI works on the latest saved version.
assets
Contains structured graphic assets saved for the template:
- logo,
- header image,
- banners,
- icons.
Each asset contains a public media URL, label, alt text, target URL, sort order, and filename.
AI should use these URLs when building HTML and should not invent additional image URLs.
store_context
Contains basic store information, such as:
- store ID,
- locale,
- base URL.
AI can use them to understand the language and context, but it should not receive real customer or order data.
9. Troubleshooting
The job remains in pending status
Most likely cause:
- the queue consumer is not running.
Check:
bin/magento queue:consumers:start kowal.ai_email.generate.consumerThe configuration page shows access denied
Check ACL permissions for:
Kowal_AiEmailThemeGenerator::settingsAfter changing administrator permissions, sign out and sign in again.
Generation ends with a missing API key error
Check:
OpenAI API KeyMake sure the module is enabled and the configuration has been saved in the correct scope.
The AI result has completed status, but the template was not updated
Check:
Automatically Apply ResultIf the option is set to No, open the job and click:
Apply ResultThe next correction does not include the previous result
Check whether the previous result was applied using:
Apply ResultThe next generation is based on the currently saved Magento template. If the job result has completed status but has not been applied, the next job will still be based on the older template version.
The AI response was rejected
The module validates the returned JSON. It may reject the result if:
- required fields are missing,
- required fields have incorrect types,
- the template name, subject, or content is empty,
- content contains the
scripttag, - the result is not valid JSON.
Check the error message in the job and retry generation with a clearer prompt.
10. Recommended production settings
Recommended initial values:
Enabled = YesRequest Timeout = 120Maximum Retries = 2Automatically Apply Result = NoKeep Request and Response Payloads = Yes for testing, No or limited retention for productionRetention Days = 30Use manual result application until the team is confident that the prompts, selected model, and validation rules produce consistent templates.