Introduction #
AI workflows enable you to automate intelligent processing of Kafinea records. By adding an AI Prompt task to a workflow, you can have an AI model automatically analyze, summarize, translate, or classify data.
1. Create a workflow with an AI task #
- Go to Settings > Automation and Communication > Workflows
- Create a new workflow or edit an existing workflow
- Select the target module (Contacts, Invoices, Quotes, etc.)
- Define the trigger conditions
- Add an AI Prompt task
2. Configure the AI Prompt task #
The AI Prompt task consists of two parts:
The prompt ( #)
This is the text prompt sent to the AI model. You can include variables from the module to customize the query.
Example prompt:
Résume en 2 phrases le contenu de la description suivante : $description
Classifie le niveau d'urgence du ticket parmi : faible, moyen, élevé, critique.
Mapping of return fields #
For each field that the AI needs to fill in, you configure:
- Target field: the field in the record to be updated
- Specific instructions: what the AI should generate for this field
Important: The AI response must be in JSON format, with field names as keys. The system automatically extracts the data even if the response contains text surrounding the JSON.
3. Contextual data provided to the AI #
The AI task automatically sends the following to the model:
| Data | Description |
|---|---|
| Recording data | All fields in the current record |
| Parent records | Data from related records (contact, account, etc.) |
| Module Descriptions | Field names and types, selection list values |
| Detail lines | For inventory-related modules (invoices, quotes, purchase orders) |
| Organization details | Company information related to the registration |
| Document content | If the module is "Documents," the contents of the attached file |
4. Examples of use #
Automatic ticket summary #
- Module: HelpDesk
- Trigger: At creation
- Prompt: "Summarize this support ticket in one concise sentence."
- Target area :
cf_summary← Instructions: “A sentence summarizing the problem”
Contact Classification #
- Module: Contacts
- Trigger: On save
- Prompt: "Analyze this contact's information and suggest a sales segment."
- Target area :
cf_segment← instruction: "The segment among: SMEs, mid-sized companies, large enterprises, and individuals"
Product description translation #
- Module: Products
- Trigger: On save
- Prompt: "Translate the product description into English."
- Target area :
cf_description_en← instruction: "The English translation of the description"
5. Error Handling #
If the AI does not return a valid response, the workflow continues without updating the fields. Errors are recorded in the server logs:
- API key missing: Check the AI gateway configuration
- No response: the prompt may be too vague or the data may be insufficient
- JSON parsing error: the system automatically tries several parsing strategies
Tip: Check the PHP logs (
error_log) to diagnose issues with the execution of AI workflows.
6. Limits #
- The prompt length is limited by the AI model used (typically a maximum of 4,096 response tokens).
- Large image files or very long documents may be truncated.
- The workflow runs synchronously: a slow AI call can slow down processing.