YouBothAgent▾
You — Business rules and flows you own. Read these yourself.
Both — Know the idea; your agent follows the details.
Agent — Conventions and references your agent follows. Look up as needed.
Introduction▾
Tutorials▾
Core Concepts▾
Architecture▾

Interact in Service

When an order comes in, you need to inform the staff so that they can make ice cream, and when the ice cream is made, you need to notify the customer. Also, if the ice cream melts, you need to notify the customer again if they don't pick it up for a long time.
To achieve this, you need to add a service that sends periodic warnings if a served order is not finished, and a service that sends an alert message to the customer to remind them to pick up the order.

Declare Adapter

First, let's start by connecting an external API or module like an alert. You can connect an api that sends messages or emails, but in this tutorial, we'll create an api that simply prints to the console and connect it.
Modules like service, signal, document should not be directly connected to external systems, but rather created as adapters that are injected. First, let's create an adapter in the /srvkit folder with adapt(). An adapter gets its own logger as this.logger.
apps/koyo/srvkit/alarmApi.ts

Use External API

adapt() registers the adapter by itself, so there is nothing to add to option.ts. Inject it into icecreamOrderService with plug():
apps/koyo/lib/icecreamOrder/icecreamOrder.service.ts

Query in Document

A served order that nobody picks up should raise a warning. First give the document a query that selects orders by status, so the service can ask for the served ones.
Apply the query on the document.
apps/koyo/lib/icecreamOrder/icecreamOrder.document.ts
By declaring the byStatuses query in IcecreamOrderFilter, you can use list, find, count, exists, insight and other functions according to the given query conditions. For example, you can use listByStatuses, countByStatuses, and insightByStatuses functions. countByStatuses returns a number, and insightByStatuses returns db.IcecreamOrderInsight.
Now add a service function that uses listByStatuses. For easy testing, it warns 15 seconds after the order was served.
apps/koyo/lib/icecreamOrder/icecreamOrder.service.ts

Use Interval

Now, let's use interval to execute the service every 10 seconds. The interval trigger is a trigger that works internally, and can be declared in IcecreamOrderInternal.
apps/koyo/lib/icecreamOrder/icecreamOrder.signal.ts
Now, you can see the warning message printed to the console if the order is served for more than 15 seconds.

Released under the MIT License

Connect your AI to these docs

MCPhttps://akanjs.com/mcp
Copyright © 2026 Akan.js All rights reserved.System managed bybassman