Synchronise external data sources automatically
How a sync works, what it requires and how to build your own via the External Knowledge API, as an alternative to the moinAI Managed Sync.
A sync automatically keeps content from a company's tools and databases up to date in the Knowledge Base, even when it changes constantly, for example product data, course offerings, event dates or timetables. A sync job regularly fetches the data from the system and transfers only the changes: new items are created, changed items are updated and removed items are deleted.
There is no need to export and upload lists manually, and the AI agents still answer with up-to-date information every day.
Developers can build and run the sync themselves. Alternatively, moinAI sets up and runs the sync as a service: the moinAI Managed Sync.
1. Use cases
2. Sync or individual subpages
4. Your own implementation or Managed Sync
5. Requirements for your own implementation
6. External Knowledge API
6.1 Limits and error messages
7. Prepare articles for the Knowledge Base
8. Scheduling
9. Safeguards
11. Common problems
1. Use cases
A sync is worthwhile wherever data changes regularly and users ask about exactly that data. It is also the right choice if the interface of your own system does not allow individual queries and only delivers the entire data set at once. An AI agent then cannot ask for a single piece of information live. Instead, the sync stores the data in the Knowledge Base, prepared for the AI agent.
| Industry | Data from your own system | What the AI agents answer with it |
|---|---|---|
| Online shop, manufacturer | Product feed with prices, variants and availability | ‘Is this jacket available in size M?’, ‘Is this model in stock?’ |
| Gym, education provider | Course schedule with dates, rooms and trainers | ‘When is the next yoga class?’, ‘Is Monday’s class cancelled?’ |
| Trade fair, arena, event organiser | Event calendar | ‘What’s on on Saturday?’, ‘Which concerts are there in December?’ |
| Airport, transport company | Flight schedules or timetables | ‘When do you fly to Palma in the morning?’, ‘Is there a bus to Lübeck on Sundays?’ |
| Further education, university | Course offerings with available places | ‘Are there still places on the Excel course in March?’ |
| Company with many locations | Branches with addresses and opening hours | ‘Is the Hamburg branch open on Saturdays?’ |
Data with a stable structure whose entries are clearly distinct from one another is well suited. Entries that differ in only one detail, such as sizes or colours of the same product, are best combined into one article by the sync, see Prepare articles for the Knowledge Base.
2. Sync or individual subpages
Individual subpages of a website can also be added to the Knowledge Base without a sync. The sync comes into its own as soon as content changes often or new content is added continuously. It is also a good fit if the interface of your own system does not allow individual queries and only delivers the entire data set at once.
| Add subpages individually | Sync | |
|---|---|---|
| New content | Each new URL is added manually | New records are added automatically, as long as they fit the existing pattern |
| Assignment to AI agents | Each resource is assigned individually | The assignment is set once and applies to all new articles. It can be changed later. |
| Up-to-dateness | Updated every 30 days | For example, a daily comparison |
This makes all the difference for dates, available places and availability. Information that is four weeks old mentions dates that are long past or places that no longer exist.
3. How the sync works
Each run builds the complete current state from the data source, compares it with the articles the sync created earlier and transfers only the difference.
- Fetch data: The sync fetches all current records from the source. If the source cannot be reached, it stops.
- Build articles: Related records are grouped according to fixed rules and turned into articles using templates, for example one article per course with all its dates.
- Determine the delta: The sync compares the new articles with the articles it has already created, using the title. This shows what is new, what has changed and what no longer exists.
- Transfer changes: Only these changes are sent to the Knowledge Base via the interface. Unchanged articles remain untouched.
If the plan is not plausible, the run stops before it changes anything.
The sync does not need change notifications from your own system. It looks at the entire data set every time, so a missed change is picked up in the next run.
4. Your own implementation or Managed Sync
You can build the sync yourself or have moinAI set it up and run it as a service.
| Your own implementation | moinAI Managed Sync | |
|---|---|---|
| Set-up | Your own developers, with your preferred software and infrastructure | moinAI, together with your team |
| Operation and monitoring | Your own team | moinAI: every run is logged and anomalies are detected |
| Data preparation | According to your own rules | Rule-based and without generative AI, the content is not reworded |
| Requirements | Development capacity, a runtime environment with scheduling and an API key | Access to the data source and agreement on which data belongs in the Knowledge Base |
| Data sources | Anything your own developers can connect | REST APIs with API key or OAuth 2.0, feeds and files (CSV, JSON, XML, TXT) and cloud storage such as AWS S3 or Google Cloud Storage |
Recommendation: For the Managed Sync, the Customer Success Team is the right point of contact. Together, you check whether the data source is suitable, and moinAI then implements the Managed Sync.
5. Requirements for your own implementation
For your own implementation, you need four things from moinAI and two from your own environment.
| What | Where from | Note |
|---|---|---|
| API key | moinAI Customer Success Team or technical support | One key per AI chatbot. With several AI chatbots, each has its own key. Store the key as a secret, never in the code or in version control. |
| Agent ID(s) | moinAI Hub, see Preparation in the Hub | Defines which AI agent may use the articles |
| Channel ID(s) | Value channelid in the integration code of the chat widget, see Website integration |
Defines the channel in which the articles are used |
| Test environment | Customer Success Team | On request, a test chatbot with its own API key may be available. This lets you try out the sync without changing the live Knowledge Base. |
| Read access to the data source | Your own systems | A REST API, a feed (JSON, CSV, XML, TXT) or export files in cloud storage, such as AWS S3 or Google Cloud Storage |
| Runtime environment with scheduling | Your own infrastructure | A server, container or serverless function that starts a script once a day. Any programming language can be used. |
Note: Each AI chatbot has a quota for the total number of characters of all articles created via the interface. Before the first import, estimate the volume of data (number of articles × average characters per article) and check it with the Customer Success Team.
Important: The sync gives every article it creates an identifier in the metadata, for example the category course_schedule and the author sync-job. It only updates or deletes articles with exactly this identifier, and manually maintained content remains untouched. Each sync needs its own category.
6. External Knowledge API
The sync writes to the Knowledge Base via the External Knowledge API. Each request is authenticated with the API key. The interface only manages articles that were created through it. It neither sees nor changes websites, PDFs or other resources in the Knowledge Base. All technical details are described in the developer documentation.
| Action | What the sync uses it for |
|---|---|
| Retrieve articles | Load the existing articles page by page to compare them with the source |
| Create article | Create an article for a new record |
| Update article | Overwrite a changed article, only the fields sent are changed |
| Delete article | Remove an article whose record is missing from the source |
The developer documentation also describes which fields an article has and which values are allowed. Two points are particularly important for the sync:
- Identifier: The category and author in the metadata together form the sync’s identifier and determine which articles it updates and deletes. All other articles remain untouched.
- Assignment: The sync only sets the assignment to AI agent and channel (
activeOn) when creating an article. Later corrections are made manually in the moinAI Hub.
A newly created article has the status uploading until it is indexed, then active.
6.1 Limits and error messages
The interface reports errors via the HTTP status.
| HTTP status | Cause | Recommendation |
|---|---|---|
| 400 | Invalid input, such as nested metadata | Stop the run and log the interface’s message |
| 404 | Article not found | Ignore when deleting, the article is already gone |
| 422 | The AI chatbot’s character quota would be exceeded | Stop the run and contact the Customer Success Team |
| 429 | Write limit exceeded: 15,000 characters per minute | Wait and retry with increasing pauses |
The write limit matters mainly for the first run. 500 articles with around 1,000 characters each add up to 500,000 characters, so the initial import takes just over half an hour. The daily runs after that only transfer changes and usually finish in seconds.
7. Prepare articles for the Knowledge Base
The structure of the articles has a greater impact on answer quality than the technology behind them. AI agents find articles via a semantic search. Each article should therefore be easy to find and unambiguous.
- One topic per article: One product, one course, one event or one location.
- Group entries that differ in only one detail: Sizes and colours of the same product or all dates of the same course belong in one article, with one line per variant. Grouping improves answer quality. Group by a fixed key, such as product number or course name.
- Clear, descriptive titles: ‘Course: Morning Yoga’ works, ‘ID 4711’ does not. The title is also the sync’s key and must remain stable.
- Context via fixed templates: Each article starts with a sentence naming the topic, and each value has a label in front of it (‘Room: Studio 1’ instead of ‘Studio 1’). The search cannot classify plain lists of values well.
- Rule-based preparation without generative AI: Fixed templates take over the data unchanged, and the same data always produces the same article. A language model could reword prices or dates and make every run look like a change.
- Consistent output: Entries are always sorted in the same way, and timestamps such as ‘created on’ are left out. Otherwise, every article differs in every run and is updated each time.
- Leave out what nobody asks about: Internal item numbers, supplier data or logistics fields usually just get in the way. Define field by field, and record in writing, which data belongs in the Knowledge Base.
- Remove what no longer applies: Past dates, discontinued products or expired offers are filtered out during preparation so that the AI agent never mentions them.
- Keep articles focused: Long articles are automatically split into sections for the search, with Markdown headings used as break points. As a rule of thumb, an article stays well below 15,000 characters, the write limit per minute.
- Write in the AI agent’s language: The articles are written in the language in which the AI agent answers.
- Link to the original: The
sourcefield contains the product or booking page. The chat widget shows it as the source of the answer. - Store your own IDs in the metadata: A key such as a product ID makes each article traceable to your own system.
Recommendation: With several languages or markets with different prices or availability for the same product, check with the Customer Success Team before defining the article structure.
8. Scheduling
The sync works best once a day, ideally at night when the data does not change. Any scheduler that can start a script is suitable, ideally the one already in use.
Check in advance whether the scheduler limits the runtime. Because of the write limit, the initial import takes much longer than the daily runs and is therefore run separately once if needed.
Regardless of the tool:
- Two runs of the same sync must never overlap, otherwise duplicates can occur.
- The API key is kept in the secret store and only passed at runtime.
- Set up a notification for failed runs. A stopped run changes nothing, and an interrupted run is completed the next time.
- Running the sync more often than daily is only worthwhile if the data really changes that quickly. Each run uses up write limit for the changed articles, and new content needs a moment to be indexed.
9. Safeguards
The most serious mistake a sync can make is deleting good content because the source had a bad day. That is why the sync should include checks that apply before every change.
| Risk | Recommended safeguard |
|---|---|
| The source cannot be reached | Stop the run. Never continue with an empty list, as this would delete all articles. |
| The source delivers no records | Stop before any change, unless emptying is explicitly intended |
| A large share of the articles would be deleted | Stop above a threshold, for example if more than half of the sync’s articles would be removed |
| Almost all articles change at once | Issue a warning, as the structure of the source has usually changed |
| The article list from moinAI arrives incomplete | Stop instead of creating duplicates. Retrieve articles page by page and check the total. |
| Two records result in the same title | Stop and report the duplicate title |
| Write limit exceeded (429) | Wait and retry with increasing pauses |
| Character quota reached (422) | Stop, articles already transferred remain |
| A run stops halfway through | The next run completes the comparison and removes duplicates |
Other proven practices:
- Test first, then write: A test run (dry run) calculates the complete plan and logs what would be created, updated and deleted, without changing anything. It is recommended before the first run against the live chatbot and before intended bulk changes.
- Stop if fields are missing: Mandatory fields are read strictly from the source. A renamed field then stops the run instead of creating articles with gaps.
- Log enough: For each run, record the plan, every title created, updated and deleted, and the summary. Keep the logs for a few weeks, and never include the API key.
10. Ongoing operation
Once the sync is running, it needs little attention. However, someone in your own team should be responsible for it. The summary of each run is important: on a normal day, only a few articles change. Many deletions, lots of changed articles at once or weeks without any change even though the data changes are signals to take a closer look.
| Situation | What happens | What to do |
|---|---|---|
| A field in the source is renamed or removed | If the sync reads mandatory fields strictly, the run stops, otherwise the value is silently missing from the articles | Adjust the preparation, do a test run, then let it run normally again |
| A new field is added | It is ignored until it is added to the template | Decide whether users ask about it and, if so, extend the template |
| A template is changed | All articles change in one run, which takes longer because of the write limit | Do a test run first, ideally outside business hours |
| The website or API is rebuilt | URLs, IDs or structures may change completely | Check the whole sync before the relaunch |
| The text of a synchronised article is changed in the moinAI Hub | The next run detects the difference and restores the text from the source | Change the source, not the article. The sync is responsible for the content. |
| The assignment of an article to an AI agent is changed in the Hub | The change is kept if the sync only sets the assignment when creating the article | Recommended implementation |
| Articles are created manually | They have no sync identifier, so the sync does not touch them | No action needed |
| The API key may have fallen into the wrong hands | The key can be used to change the articles | Request a new key from the Customer Success Team or support |
11. Common problems
Problems with the sync are usually caused by the API key, the limits of the interface, the data preparation or the assignment to AI agents.
| Problem | Likely cause | Solution |
|---|---|---|
| Authentication error | Missing or wrong key, or the key of another AI chatbot | Check whether the key is sent and which AI chatbot it belongs to |
| Error 400 ‘Validation error’ | Nested metadata, a title with fewer than 3 characters or empty content | Limit metadata to text, numbers and Boolean values, check titles and content |
| Error 422 | The AI chatbot’s character quota has been used up | Remove content that is no longer needed or contact the Customer Success Team |
| The first run takes a very long time | The write limit of 15,000 characters per minute | This is normal. Run the initial import separately from the daily schedule. |
| Every run updates all articles | The article texts are not consistent, for example because of unsorted entries or timestamps | Sort entries and remove everything that changes with each run |
| Duplicate articles | Two runs overlapped, or two syncs use the same identifier | Prevent overlapping runs, use a separate category per sync |
| The run stops because of too many deletions | The source only delivered part of the data | Check the source. If the deletions are intended, raise the threshold for one run. |
| Articles exist but are not used | Wrong agent or channel IDs in activeOn, or the article is still being indexed |
Assign the affected articles manually to the correct AI agent or channel in the moinAI Hub. The sync only sets activeOn when creating an article and deliberately does not correct the assignment, not even in a new run. If indexing is still in progress, wait for the status active. |
| The AI agent mixes up similar products or dates | Many almost identical articles | Group variants into one article per product or course |
Recommendation: All technical details of the interface are described in the External Knowledge API in the developer documentation. How to connect an external knowledge base is described in the article Connect an external knowledge base.