Workflow bindings

Do anyone knows is there any way (or plans) how to integrate Zaraz custom components together with Workflows through bindings (without using the middle Worker)? @Mackenly maybe you know something?
6 Replies
Mackenly
Mackenly2w ago
You can using Bindings in custom managed components. I haven't personally used it with Workflows though. I don't work for Cloudflare, so I'm limited to just my experience. What's the use case?
m.muiznieks
m.muiznieksOP2w ago
Yes, I know about the Bindings in general, and I found out that through one of your GH repo examples. I'm using the MC in more than one page and working on custom GA4, FB event processing and want to "remove" that functionality from the MC itself, instead sending and processing the events separately (which includes saving some events on D1 as well). While exploring the Workflows I thought this might be a good use for them. I ask this because I see that MC publishing uses the old 3.29 Wrangler version, which does not recognize the Workflows in wrangler.toml Other way around is using http fetch of course, but..
m.muiznieks
m.muiznieksOP2w ago
So, I am reading here: https://developers.cloudflare.com/workflows/build/call-workflows-from-pages/#use-service-bindings That Workflows can be triggered and connected as the Service Bindings. I made a template Workflow without any modifications made (so the code is useless here). I'm trying to get it alive as this:
export interface Manager extends OriginalManager {
ext: {
env: {
KV: KVNamespace;
KV2: KVNamespace;
SERVICE_WORKER_THAT_WORKS: {
fetch: (url: string, init: RequestInit) => Promise<Response>;
};
WORKFLOW: Workflow; //Does not work
// WORKFLOW_TEST_2: Service; //Does not work
// WORKFLOW_TEST_3: {
// run: (options?: WorkflowInstanceCreateOptions<unknown> | undefined) => Promise<WorkflowInstance>; //this is named as the actual function in template
// };
// WORKFLOW_TEST_4: {
create: (options?: WorkflowInstanceCreateOptions<unknown> | undefined) => Promise<WorkflowInstance>;
//...
};

};
};
}
export interface Manager extends OriginalManager {
ext: {
env: {
KV: KVNamespace;
KV2: KVNamespace;
SERVICE_WORKER_THAT_WORKS: {
fetch: (url: string, init: RequestInit) => Promise<Response>;
};
WORKFLOW: Workflow; //Does not work
// WORKFLOW_TEST_2: Service; //Does not work
// WORKFLOW_TEST_3: {
// run: (options?: WorkflowInstanceCreateOptions<unknown> | undefined) => Promise<WorkflowInstance>; //this is named as the actual function in template
// };
// WORKFLOW_TEST_4: {
create: (options?: WorkflowInstanceCreateOptions<unknown> | undefined) => Promise<WorkflowInstance>;
//...
};

};
};
}
I tried various ways, up there are few of what I tried. The only thing that works is fetching. What I get is the error:
X [ERROR] TypeError: The RPC receiver does not implement the method "create".
X [ERROR] TypeError: The RPC receiver does not implement the method "create".
This error is for whatever I try (except fetching). Adding a note for this - for the SERVICE_WORKER_THAT_WORKS I have few more methods, that works at other cross-worker bindings, but with zaraz custom managed component I get the same error as above. the Bindings in wrangler.toml
binding = "WORKFLOW"
service = "wf-name-in-cf"
entrypoint = "MyWorkflow"
binding = "WORKFLOW"
service = "wf-name-in-cf"
entrypoint = "MyWorkflow"
I tried with and without entrypoint. Adding the [[workflows]] does not work also, as it throws warning, that it is not recognized and does not appear to bindings.
Cloudflare Docs
Call Workflows from Pages · Cloudflare Workflows docs
You can bind and trigger Workflows from Pages Functions by deploying a Workers project with your Workflow definition and then invoking that Worker using service bindings or a standard fetch() call.
m.muiznieks
m.muiznieksOP2w ago
@yo'av Sorry for disturbing you, but I believe you are one of few who can make some comments about this topic (and I hope you will).
Mackenly
Mackenly2w ago
Yes, the MC to Worker script needs some dependency updates (see PR, which may itself be outdated at this point). Following to see if you're able to get it to work!
m.muiznieks
m.muiznieksOP7d ago
For now, I think there is no better way than firing the http post request to the specific workflow. Ok, I still hope for some updates. :/

Did you find this page helpful?