Getting Started
A service is a program that connects to Requence, receives messages, processes them, and returns results. Services are the building blocks of every task template.
Prepare
Section titled “Prepare”Before writing any code, create the service in the Requence UI. Define its input schema, configuration schema, and outputs — including an output schema for each. Requence uses these definitions to validate data at design time and route messages at execution time.
Installation
Section titled “Installation”npm install @requence/servicepip install requenceAuthentication
Section titled “Authentication”Every service needs an access token to connect to Requence. In the services list view, click the Copy credentials button to copy the access token to your clipboard.
The token is resolved in this order:
accessTokenoption passed tocreateService()REQUENCE_SERVICE_ACCESS_TOKENorREQUENCE_ACCESS_TOKENenvironment variablerequence.service.accessTokenorrequence.accessTokeninpackage.json
REQUENCE_SERVICE_ACCESS_TOKEN=your-token bun run index.tsaccess_tokenkey in the config dict passed toService()REQUENCE_SERVICE_ACCESS_TOKENorREQUENCE_ACCESS_TOKENenvironment variablerequence.service_access_tokenorrequence.access_tokeninpyproject.toml
REQUENCE_SERVICE_ACCESS_TOKEN=your-token python main.pyYour Implementation
Section titled “Your Implementation”import { createService } from '@requence/service'
createService('1.0.0', (ctx) => { const input = ctx.input
return { message: `Hello, ${input.name}!` }})from requence.service import Service
def handler(ctx): input = ctx.input return {"message": f"Hello, {input['name']}!"}
Service("1.0.0", handler)That’s it. When Requence dispatches a message to this service, the handler runs and the return value is sent back as the service’s result.
Next Steps
Section titled “Next Steps”Learn about the full Context API available inside your message handler.