Can’t you start another workflow from an existing workflow?
Can’t you start another workflow from an existing workflow?



wrangler.toml file. I'm not seeing the wrangler command to create new workflows. When I add the bindings and deploy it out, it is just undefined. I'm running the latest version of wrangler with a current compatibility date. What am I missing?await env.MY_WORKFLOW.create(), env.MY_WORKFLOW itself is undefined. Do you need to do anything more than simply adding the [[workflows]] config in the wrangler.toml? And export the relevant workflow class from the main entry point?
wrangler.tomltypes.tssrc/index.ts./incoming-emails/forward-email-handler./incoming-emails/workflownpx wrangler workflows list show? Do your Workflow names match? Bindings type when you’re instantiating your Hono app instances? There are no deployed Workflows in this account. This is why I thought that you need something more than just the config in wrangler.toml for the deployment to work.[[workflows]].binding matches what I use for env.PROCESS_INCOMING_EMAILS_WORKFLOW as well as what I set on the Bindings type. And [[workflows]].class_name matches the name of my workflows class export, ProcessIncomingEmailsWorkflow.[[workflows]].name be any arbitrary name or what should that match?app.tstypes.ts
Can [[workflows]].name be any arbitrary name or what should that match?

[[workflows]]
name = "process-unstructured-nutrition-data"
binding = "PROCESS_UNSTRUCTURED_NUTRITION_DATA"
class_name = "ProcessUnstructuredNutritionData"
[[workflows]]
name = "photo-meal-analysis"
binding = "PHOTO_MEAL_ANALYSIS"
class_name = "PhotoMealAnalysis"
[[workflows]]
name = "text-meal-analysis"
binding = "TEXT_MEAL_ANALYSIS"
class_name = "TextMealAnalysis"type Env = {
// Add your bindings here, e.g. Workers KV, D1, Workers AI, etc.
MY_WORKFLOW: Workflow;
};types.tstypes.ts./incoming-emails/forward-email-handler./incoming-emails/workflownpx wrangler workflows listBindingsBindingsThere are no deployed Workflows in this account[[workflows]].bindingenv.PROCESS_INCOMING_EMAILS_WORKFLOW[[workflows]].class_nameProcessIncomingEmailsWorkflow[[workflows]].nameapp.ts[[workflows]]
name = "process-incoming-emails"
binding = "PROCESS_INCOMING_EMAILS_WORKFLOW"
class_name = "ProcessIncomingEmailsWorkflow"import type { Workflow } from '@cloudflare/workers-types';
export type Bindings = {
// ...other bindings
PROCESS_INCOMING_EMAILS_WORKFLOW: Workflow;
};import { app } from './app'; // Hono app
import type { Bindings } from './types';
import { handleForwardingIncomingEmails } from './incoming-emails/forward-email-handler';
export { ProcessIncomingEmailsWorkflow } from './incoming-emails/workflow';
const handler = {
fetch: app.fetch,
async email(message, env, ctx) {
await handleForwardingIncomingEmails(message, env, ctx);
},
} satisfies ExportedHandler<Bindings>;export const handleForwardingIncomingEmails = async (
message: ForwardableEmailMessage,
env: Bindings,
_ctx: ExecutionContext,
) => {
return withLogTags(
{
tags: {
handler: 'email',
requestId: crypto.randomUUID(),
},
},
async () => {
const [address] = addressParser(message.to);
if (!address?.address) {
logger.warn('No email address found in `to` field');
return message.setReject('No email address found in `to` field');
}
logger.log('Workflow defined', {
defined: !!env.PROCESS_INCOMING_EMAILS_WORKFLOW, // <-- Not defined here!
});
// await env.PROCESS_INCOMING_EMAILS_WORKFLOW.create({
// params: {
// message,
// },
// });
}
)
}export class ProcessIncomingEmailsWorkflow extends WorkflowEntrypoint<
Bindings,
Params
> {}import { createFactory } from 'hono/factory';
import { Env } from './types';
export const factory = createFactory<Env>({
initApp: (app) => {
app.use(async (c, next) => {
// Make supabase client available to all requests
const supabase = createClient(c.env.SUPABASE_URL, c.env.SUPABASE_KEY);
c.set('supabase', supabase);
await next();
});
},
});
export const app = factory.createApp();import type { Workflow } from '@cloudflare/workers-types';
export type Bindings = {
// ...other bindings
PROCESS_INCOMING_EMAILS_WORKFLOW: Workflow;
};
export type Env = {
Bindings: Bindings;
Variables: Variables;
};