Placeholders Support
You can use placeholders in string configuration fields and easily resolve them with values from the task input payload or other parameters.
configuration
example-task-default:
config:
prompt: "Say hello to ${name} !"
usage
@Executor("example-task")
export class ExampleExecutor implements TaskExecutor {
async processTask(
exampleCommand: ExampleCommand,
meta: TaskMetadata,
flow: Flow
): Promise<ExampleResponse> {
const config = flow.config
.withFieldParams("prompt", {
name: 'Joe'
})
.get();
return {
result: config.message // `Say hello to Joe !`
};
}
}
method applyPlaceholders
configuration
example-task-default:
config:
prompt: "Say hello to ${name} !"
@Executor("example-task")
export class ExampleExecutor implements TaskExecutor {
async processTask(
exampleCommand: ExampleCommand,
meta: TaskMetadata,
flow: Flow
): Promise<ExampleResponse> {
const template = await flow.config.get();
const result = flow.config.applyPlaceholders(template.prompt, {
name: 'Joe',
});
return {
result // "Say hello to Joe!"
};
}
}