Appearance
Class: AppServiceModel
Represents a service exposed by an app: a named, described and typed function that another context (widget, AI bot, AI assistant, etc.) can call.
Remarks
You do not instantiate this class directly: it is created and returned by k.services.create(...).
Example
ts
const service = await k.services.create({
name: 'givePoints',
description: 'Give points to a viewer',
domains: ['aibot'],
args: [{ name: 'login', type: 'string', description: 'The viewer', required: true }],
call: async (args) => { ... },
});Properties
args
ts
args: AppServiceArgumentData[] = [];List of arguments expected by the service.
call
ts
call: AppServiceCallFunction;Function executed when the service is called.
description
ts
description: string;Description of the service intended for humans.
description_for_ai
ts
description_for_ai: string;Description of the service intended for the AI.
domains
ts
domains: string[] = [];Contexts allowed to call the service (*, app, widget, aibot, aiassistant).
granted_role
ts
granted_role: AppServiceGrantedRole;Minimum role for AI calls on behalf of a user; see AppServiceGrantedRole.
name
ts
name: string;Unique name of the service (used as the identifier to call it).
type?
ts
optional type?: string;Free-form category / type of the service.
Methods
remove()
ts
remove(): Promise<void>;Removes this service: it will no longer be callable by other contexts.
Returns
Promise<void>
A promise resolved once the service has been removed.