New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom extension does not trigger workflows using js custom event #1706
Comments
help me? Custom extension does not trigger workflows using js custom event #1706 |
@jlopez994 Have you solved the problem yet? How was it resolved? Can you help me see what's going on? |
Hey @lslcoded, I found a workaround until a proper solution be proposed. I was checking out to the extension source code, and I saw they emit some messages to the background script in order to start the workflow, so I decided to replicate this behavior instead of calling the event. (which btw seems to be not handled in the extension) This is the code I created from the source: const executeWorkflow = async (id, variables) => {
try {
const data = { workflowId: id, workflowOptions: { data: { variables } } };
const workflow = await getWorkflow(data.workflowId);
if (!workflow) throw new Error(`Can't find workflow with ${data.workflowId} Id`);
const n = data.workflowOptions;
sendMessage('workflow:execute', { ...workflow, options: n }, 'background');
} catch (e) {
console.error(e);
}
};
const getWorkflow = async (id) => {
const t = ((await chrome.storage.local.get('workflows')).workflows || []).filter(
(e) => !e.invisible
);
if (id) return t.find((t) => t.id === id);
return t;
};
const sendMessage = (event, options, type) => {
let i = { name: type ? type + '--' + event : event, data: options };
return chrome.runtime.sendMessage(i);
}; And I just call the In my case, I have a background process in the popup window, which receives info through websockets, and calls this function in order to run a workflow. I guess it'd work also inside of a workflow, but I didn't test it. Hope it helps! |
What file should these JavaScript scripts be placed in and where should they be executed specifically! |
Describe the bug
When I try to trigger a workflow from my extension, using a JavaScript component, nothing happens.
To Reproduce
Steps to reproduce the behavior:
automa:execute-workflow
using the id from the workflows page.This is the code I tried in the js component:
Expected behavior
The workflow should be triggered as it does in the Automa extension
Screenshots
This is where I get the workflow id.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: