-
Notifications
You must be signed in to change notification settings - Fork 8
AI Integration
Warning
AI-generated translations and cookie descriptions may occasionally be inaccurate or misleading. Always review and verify the output.
Pressidium Cookie Consent integrates with AI to allow users to translate the cookie consent banner, or generate descriptions for the cookies used on the website. The plugin supports multiple AI providers, including OpenAI and Google, with models like gpt-4o
and gemini-2.0-flash
.
Before using the AI integration, it’s highly recommended to specify the PRESSIDIUM_COOKIE_CONSENT_ENCRYPTION_KEY
and PRESSIDIUM_COOKIE_CONSENT_ENCRYPTION_SALT
constants in your wp-config.php
file. These constants are used to encrypt and decrypt the API keys you enter.
If you do not specify these constants, the plugin will use the default WordPress LOGGED_IN_KEY
and LOGGED_IN_SALT
constants for encryption.
Warning
Once the PRESSIDIUM_COOKIE_CONSENT_ENCRYPTION_KEY
and PRESSIDIUM_COOKIE_CONSENT_ENCRYPTION_SALT
constants are set, they should never be changed. Changing these constants will result in the loss of all previously stored API keys, and you will need to re-enter them.
To set the constants, add the following lines to your wp-config.php
file:
define( 'PRESSIDIUM_COOKIE_CONSENT_ENCRYPTION_KEY', 'your_encryption_key' );
define( 'PRESSIDIUM_COOKIE_CONSENT_ENCRYPTION_SALT', 'your_encryption_salt' );
Replace your_encryption_key
and your_encryption_salt
with your own values. You can generate a random key and salt using the WordPress.org secret key generator: https://api.wordpress.org/secret-key/1.1/salt/
Navigate to wp-admin → Cookie Consent → Translations, select a language to translate and click the “AI Settings” button.
Alternatively, you can access the AI settings by clicking the “AI Settings” button in the AI toolbar.
Select the AI provider you want to use, and enter your API key.
Currently, the plugin supports the following AI providers:
To generate your keys, follow the instructions provided by the respective AI provider. For more information, refer to the following links:
Enter your API key in the “API key” field and click “Add API key” to save it. The key will be encrypted and stored in the database.
You can click the “Remove API key” button to delete the key from the database. The key will be removed from the database, but it will not be deleted from the AI provider’s account.
You can select the AI model you want to use for translations and cookie descriptions. Model availability varies based on your selected AI provider and what your account supports.
Explore available models and compare their capabilities on the respective provider’s website:
That’s it! You have successfully configured the AI integration. You can now use the AI features to generate translations and cookie descriptions 🎉
You can either generate translations for a specific text field or text area, or translate all text fields and text areas for the selected language.
To translate a specific text field or text area, select the text you want to translate and click the “AI Translate” button in the AI toolbar.
An animation will play while the AI is generating the translation. Once the translation is complete, it will be automatically inserted into the text field or text area.
To translate all text fields and text areas for the selected language, click the “AI Translation” button at the top of the panel.
An animation will play for each text field and text area the AI is generating the translations for. Once all translations have been successfully generated, they will be automatically inserted into the text fields and text areas.
Navigate to wp-admin → Cookie Consent → Cookies, select a cookie to generate a description for, and click the “AI Generate” button in the AI toolbar.
An animation will play while the AI is generating the description. Once the description is complete, it will be automatically inserted into the description field.
If the AI is unable to generate a description, an error message will be displayed instead.
If you encounter any issues with the AI integration, please check the following before opening an issue.
Ensure that you have:
- completed the entire setup process
- entered a valid API key for the selected AI provider
- selected a valid AI model that is supported by your account
Something went wrong while fetching AI models. Is your API key valid?
This error message indicates that the plugin was unable to fetch the available AI models from the selected provider. This could be due to an invalid API key or a temporary issue with the provider’s API.
Please check your API key and ensure that it is valid for the selected provider. You can also try again later to see if the issue resolves itself.
Translation failed. Double-check your AI settings — the integration may not be fully configured.
This error message indicates that the AI integration is not fully configured. You may have attempted to generate a translation without entering a valid API key or selecting a valid AI model.
Please check your AI settings and ensure that you have entered a valid API key and selected a valid AI model.
The AI does not have enough information to generate a description for this cookie. Please provide a description manually.
This error message indicates that the AI was unable to generate a description for the selected cookie. This is intended behavior, as the AI may not have enough information to generate a accurate description, so an error message is displayed instead of providing potentially inaccurate information.
Please provide a description manually for the selected cookie.
If you encounter any other issues with the AI integration, please open an issue.