Skip to content

Install AI Actions

AI Actions are available as an LTS update to Ibexa DXP starting with version v4.6.12 or higher, regardless of its edition. To use this feature you must first install the package. You can then install and configure the service connectors or build your own ones.

Install the framework

Run the following command to install the package:

1
composer require ibexa/connector-ai

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

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.

Next steps

Once the framework is installed and configured, before you can start using AI Actions, you can configure access to [[ = product_name_base = ]]-made service connectors by following the instructions below, or create your own.

Only then you can restart you application and start working with the AI Actions feature.

Configure access to OpenAI

Run the following command to install the service connector with the OpenAI service:

1
composer require ibexa/connector-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=<your_api_key>
###< ibexa/connector-openai ###

Install sample OpenAI 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.

Configure access to Ibexa Connect

First, get the credentials by contacting Ibexa Support.

Create team

In Ibexa Connect, set up the account, and create a team. Navigate to the team details page and note down the numerical value of the Team id variable.

Creating a team matters, because scenarios that process data coming from your AI action are associated with a team. This way, if your organization has more than one Ibexa DXP project, each project can be linked to a different team and so can be scenarios used in those projects.

If specific users from the team are supposed to modify scenario settings, you must assign the right roles to them.

Create token

Navigate to your Ibexa Connect user's profile, and on the API ACCESS tab, create a new token. Copy the token code that appears next to the label.

Creating an API token

Set up credentials

In the root folder of your project, modify the .env file. Replace a placeholder value of the IBEXA_CONNECT_TOKEN variable with the token that you got from Ibexa Connect and provide a value of the IBEXA_CONNECT_TEAM_ID variable.

1
2
3
4
5
6
7
8
9
###> ibexa/connect ###
IBEXA_CONNECT_HOST=https://connect.ibexa.co
IBEXA_CONNECT_API_PATH=/api/v2/
# Token can be created in the user's profile in Ibexa Connect, under the 'API ACCESS' section.
IBEXA_CONNECT_TOKEN=<your_api_token>
# Use the URL below to read more on Ibexa Connect teams.
# https://doc.ibexa.co/projects/connect/en/latest/access_management/teams/
IBEXA_CONNECT_TEAM_ID=2
###< ibexa/connect ###

Initiate integration

Initiate the models provided by the handler by issuing the following command:

1
php bin/console ibexa:connect:init-connect-ai <team_id> <language> <action handler identifiers>

For example:

1
php bin/console ibexa:connect:init-connect-ai 2 en connect-image-to-text connect-text-to-text

Support for multiple Ibexa Connect languages

The language attribute determines the language in which template details such as module names will be displayed in Ibexa Connect's UI.

Customize templates

Return to the Ibexa Connect dashboard and modify the Template for connect...handler templates by defining the logic needed to process the data.

Once the templates are ready, you can build scenarios from them, either directly in Ibexa Connect or in Ibexa DXP's user interface.