Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

@commandkit/workflow

Package Overview
Dependencies
Maintainers
2
Versions
230
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commandkit/workflow

CommandKit plugin for useworkflow.dev

latest
Source
npmnpm
Version
1.2.1
Version published
Maintainers
2
Created
Source

@commandkit/workflow

CommandKit plugin for useworkflow.dev.

Installation

npm install @commandkit/workflow workflow

Usage

import { defineConfig } from 'commandkit/config';
import { workflow } from '@commandkit/workflow';

export default defineConfig({
  plugins: [workflow()],
});

Then, add workflow functions inside src/workflows directory.

import { sleep } from 'workflow';
import { useClient } from 'commandkit/hooks';

export async function greetUserWorkflow(userId: string) {
  'use workflow';

  await greetUser(userId);

  await sleep('5 seconds');

  await greetUser(userId, true);

  return { success: true };
}

async function greetUser(userId: string, again = false) {
  'use step';

  const client = useClient<true>();

  const user = await client.users.fetch(userId);

  const message = again ? 'Hello again!' : 'Hello!';

  await user.send(message);
}

Now, you can run the workflow using the start function in your commands (or other places).

import { start } from 'workflow/api';
import {greetUserWorkflow} from '@/workflows/greet';

export const command: CommandData = {
    name: 'greet',
    description: 'Greet command',
};

export const chatInput: ChatInputCommand = async (ctx) => {
    await ctx.interaction.reply("I'm gonna greet you :wink:");
    await start(greetUserWorkflow, [ctx.interaction.user.id]);
}

Using custom Worlds

You can use any world providers from useworkflow.dev/worlds or create your own custom world. Refer to the Building a World documentation for more details.

Documentation

https://commandkit.dev/docs/next/api-reference/workflow

Keywords

commandkit

FAQs

Package last updated on 09 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts