A content import workflow
This page is for developers who let an agent import content, for example items from a partner's feed, into a folder of the site. It shows a workflow in which every write is limited, rehearsed and checked.
Contents
- The task
- Prepare the account
- Choose the interface
- Rehearse on a test installation
- Run it
- Check it
- Variations
The task
An outside feed lists events. The agent reads each item, maps it onto the fields of the event class (title, date,
summary, body) and creates one object per new item in a folder "Partner events".
The feed is untrusted text: its fields can contain anything (Untrusted data and prompt injection).
Prepare the account
Create an account for the import, in its own user group.
Give its role
content/read, andcontent/createlimited to the classeventand the subtree of "Partner events". Addcontent/removethere only if the import should remove items.Check the result before any write.
exp:access:checkanswers for read, edit, remove and the other functions of an existing node, for example that the account may read the folder but not edit other pages:./console exp:access:check --user=<import login> --node=<Partner events node id> ./console exp:access:check --user=<import login> --node=<another page> --function=editCheck the create right itself on the test installation by creating one item as that account (Roles and least privilege).
Signed in as that account, make a personal API key with the scope
publish(andread), and a short lifetime (A read-only API key, step by step shows the same steps forread).
Choose the interface
| Interface | Fits when | Note |
|---|---|---|
REST v2 content/node/create with the import account's key | The agent runs anywhere; items are only ever added | Create and publish (Agents and the REST API) |
| expservices with a token of the import account | You need services beyond content as well | Check the catalog entry and the write flag of each service (Agents and expservices) |
The steps below use REST v2.
Rehearse on a test installation
Never let a new import write to production first. Use a copy or a fresh test installation, run the whole workflow there, read the results as an editor would, and only then point the agent at production.
Run it
- Map: the agent reads the class definition from documentation or a sample object (
GETon an existing event withResponseGroups=Fields) and maps feed fields onto attribute identifiers. Your code, not the model, checks that every identifier exists. - Validate in code: dates parse, required fields are present, text is plain or allowed markup, links use http(s). The model proposes; your code decides.
- A person reads the first batch: a few mapped items as plain data, before anything is sent.
- Write: one
POST /api/ezp/v2/content/node/createper item, withparentNodeID,classIdentifier,languageLocaleand the attributes. Record the new node ids. - Remember what was imported: keep the feed id with the new node id in your own store, so a second run creates only new items.
Check it
- Look at the kernel's audit trail for the import account's actions (The audit trail for AI).
- Open a few items in the administration as an editor.
- Compare counts: items in the feed, items sent,
201answers, objects in the folder.
Variations
- People must approve imported items: import into a section that visitors cannot see and that an approval workflow covers (Keeping a person in the loop).
- Updates and removals: give the account
content/editorcontent/removeonly for the folder, use the matching key scopes, and rehearse them separately. - Large imports: send in small batches and stop the run on the first
401or403; those mean a person must look.
Related pages
- Choosing an interface for an agent
- Creating content in code
- Before connecting an agent
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.