Skip to content

Install AI Actions

AI Actions are available as an LTS update to Ibexa DXP in version v4.6.x or higher, regardless of its edition. To use this feature you must first install the packages and configure them.

Install packages

Run the following commands to install the packages:

1
2
composer require ibexa/connector-ai
composer require ibexa/connector-openai

This command adds the framework code, a service connector with the OpenAI service, service handlers, Twig templates, and configurations required for using AI Actions. It also modifies the permission system to account for the new functionality.

Configure AI Actions

Once the packages are installed, before you can start using AI Actions, you must enable them by following these instructions.

Configure access to OpenAI

Create an OpenAI account, get an API key, and make sure that you set up a billing method.

Then, in the root folder of your project, modify the .env file: find the OPENAI_API_KEY variable and replace a placeholder value with the API key that you got from the AI service.

1
2
3
###> ibexa/connector-openai ###
OPENAI_API_KEY=sk-svcacct-AFCrCt1h2s3i4s5i6s7t8h9e0a1p2i3c4o5d6e
###< ibexa/connector-openai ###

Modify the database schema

Create the add_ai_actions.sql file that contains the following code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
CREATE TABLE ibexa_action_configuration
(
    id                        INT auto_increment PRIMARY KEY,
    identifier                VARCHAR(64) NOT NULL,
    type                      VARCHAR(32) NOT NULL,
    enabled                   TINYINT(1) NOT NULL,
    action_type_options       JSON NULL,
    action_handler_options    JSON NULL,
    action_handler_identifier VARCHAR(64) NULL,
    created_at                DATETIME NULL COMMENT '(DC2Type:datetime_immutable)',
    updated_at                DATETIME NULL COMMENT '(DC2Type:datetime_immutable)',
    CONSTRAINT ibexa_action_configuration_identifier_uc
        UNIQUE (identifier)
) COLLATE = utf8mb4_unicode_520_ci;

CREATE INDEX ibexa_action_configuration_enabled_idx
    ON ibexa_action_configuration (enabled);

CREATE INDEX ibexa_action_configuration_identifier_idx
    ON ibexa_action_configuration (identifier);

CREATE TABLE ibexa_action_configuration_ml
(
    id                      INT auto_increment PRIMARY KEY,
    action_configuration_id INT          NOT NULL,
    language_id             BIGINT       NOT NULL,
    name                    VARCHAR(190) NOT NULL,
    description             LONGTEXT NULL,
    CONSTRAINT ibexa_action_configuration_ml_uidx
        UNIQUE (action_configuration_id, language_id),
    CONSTRAINT ibexa_action_configuration_ml_to_action_configuration_fk
        FOREIGN KEY (action_configuration_id) REFERENCES ibexa_action_configuration (id)
            ON UPDATE CASCADE ON DELETE CASCADE,
    CONSTRAINT ibexa_action_configuration_ml_to_language_fk
        FOREIGN KEY (language_id) REFERENCES ezcontent_language (id)
            ON UPDATE CASCADE ON DELETE CASCADE
) COLLATE = utf8mb4_unicode_520_ci;

CREATE INDEX ibexa_action_configuration_ml_action_configuration_idx
    ON ibexa_action_configuration_ml (action_configuration_id);

CREATE INDEX ibexa_action_configuration_ml_language_idx
    ON ibexa_action_configuration_ml (language_id);
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
CREATE TABLE ibexa_action_configuration (id SERIAL NOT NULL, identifier VARCHAR(64) NOT NULL, type VARCHAR(32) NOT NULL, enabled BOOLEAN NOT NULL, action_type_options JSON DEFAULT NULL, action_handler_options JSON DEFAULT NULL, action_handler_identifier VARCHAR(64) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id));
CREATE INDEX ibexa_action_configuration_identifier_idx ON ibexa_action_configuration (identifier);
CREATE INDEX ibexa_action_configuration_enabled_idx ON ibexa_action_configuration (enabled);
CREATE UNIQUE INDEX ibexa_action_configuration_identifier_uc ON ibexa_action_configuration (identifier);
COMMENT ON COLUMN ibexa_action_configuration.created_at IS '(DC2Type:datetime_immutable)';
COMMENT ON COLUMN ibexa_action_configuration.updated_at IS '(DC2Type:datetime_immutable)';
CREATE TABLE ibexa_action_configuration_ml (id SERIAL NOT NULL, action_configuration_id INT NOT NULL, language_id BIGINT NOT NULL, name VARCHAR(190) NOT NULL, description TEXT DEFAULT NULL, PRIMARY KEY(id));
CREATE INDEX ibexa_action_configuration_ml_name_idx ON ibexa_action_configuration_ml (name);
CREATE INDEX ibexa_action_configuration_ml_language_idx ON ibexa_action_configuration_ml (language_id);
CREATE INDEX ibexa_action_configuration_ml_action_configuration_idx ON ibexa_action_configuration_ml (action_configuration_id);
CREATE UNIQUE INDEX ibexa_action_configuration_ml_uidx ON ibexa_action_configuration_ml (action_configuration_id, language_id);
ALTER TABLE ibexa_action_configuration_ml ADD CONSTRAINT ibexa_action_configuration_ml_to_language_fk FOREIGN KEY (language_id) REFERENCES ezcontent_language (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
ALTER TABLE ibexa_action_configuration_ml ADD CONSTRAINT ibexa_action_configuration_ml_to_action_configuration_fk FOREIGN KEY (action_configuration_id) REFERENCES ibexa_action_configuration (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;

Run the following command, where <database_name> is the same name that you defined when you installed Ibexa DXP.

1
mysql -u <username> -p <password> <database_name> < add_ai_actions.sql
1
psql <database_name> < add_ai_actions.sql

This command modifies the existing database schema by adding database configuration required for using AI Actions.

You can now restart you application and start working with the AI Actions feature.

Install sample AI action configurations (optional)

By installing a collection of sample AI action configurations you can quickly start using the feature. You do it by following a standard data migration procedure:

1
2
php bin/console ibexa:migrations:import vendor/ibexa/connector-openai/src/bundle/Resources/migrations/action_configurations.yaml
php bin/console ibexa:migrations:migrate

Based on these examples, which reflect the most common use cases, you can learn to configure your own AI actions with greater ease.