Skip to content

Formula Functions

Ebla AI adds formula functions for workflows, before-save scripts, and other EspoCRM automation.

The executing user or process context needs AI and AI Formula permission.

Generate text

eblaAi\textGenerate(PROMPT, PROFILE_ID)

PROFILE_ID is optional.

Example:

$prompt = string\concatenate(
    'Write a concise summary for ',
    name,
    '. Current status: ',
    status
);

description = eblaAi\textGenerate($prompt, $profileId);

Run a saved prompt

eblaAi\runPrompt(PROMPT_ID)

The current record is used as context when the formula runs on a saved record.

Example:

notes = eblaAi\runPrompt('PROMPT_ID');

Render a saved prompt

eblaAi\getPrompt(PROMPT_ID)
eblaAi\getPrompt(PROMPT_ID, ENTITY_TYPE, RECORD_ID)

This function returns rendered prompt text and does not call the provider.

Example:

$prompt = eblaAi\getPrompt($promptId, 'Contact', contactId);
description = eblaAi\textGenerate($prompt, $profileId);

Generate an image

eblaAi\generateImage(PROMPT, SIZE, PROFILE_ID)

SIZE can be square, landscape, or portrait. The function saves the generated file as an Attachment and returns its ID.

Example:

photoId = eblaAi\generateImage(
    'Professional product photo on a white background',
    'square',
    $profileId
);

The selected provider and model must support image generation.

Error handling

Provider, permission, validation, and usage-limit failures can stop the function or return an error according to the formula context. Test automation with the intended execution user and provider before enabling it in production.

Do not place API keys or confidential configuration inside formula prompts.