Skip to content
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

Trigger an Action from a Website with CustomEvent and/or general Events #382

Closed
ZlydeTJ opened this issue Feb 25, 2022 · 14 comments
Closed
Labels
enhancement New feature or request

Comments

@ZlydeTJ
Copy link

ZlydeTJ commented Feb 25, 2022

Is your feature request related to a problem? Please describe.
I want to use the automation from my own website to automate certain actions after I'm done using the website. So e.g.: It would be nice to start a search to an internal tool directly from my website when clicking a button with the related keyword, instead of copying it and then starting my actions. Especially since I have a lot of actions available. I currently have a Chrome-Plugin that does exactly this, however it would be more convenient to also use automa for this tasks.

Describe the solution you'd like
In my plugin I use the chrome api chrome.runtime.onMessage.addListener to listen for events which I throw through the new CustomEvent(I think the plugin does already this with a different kind of website/plugin interaction). It would be nice to have an Event like this:

new CustomEvent('automa-start-workflow', {
  detail: {
    id: 'nbf6-qlwD-JCVptpnf9EF', // workflow id
    // custom data I want to pass to the workflow
    // maybe pass this as a variable? Or into the global data
    data: {
      keyword: 'Example Keyword'
    }
  }
}))

Which would start the workflow based on the id. I'm not sure what the best way would be to pass the data (maybe variable or global data).

Would this fit?

Alternatively what also would work is listening to all Button Browser events and have a certain trigger. For example if I were to post a comment on a website I would like to paste that comment also into a Google Docs Table. I could listen whenever a certain button is pressed a trigger a workflow.

This use-case is a bit broader since it also covers site that the workflow creator possible has no control over, however it would be a bit harder to pass data along, as this would first has to be scraped.

@Kholid060
Copy link
Member

That's a good idea.

In my plugin I use the chrome api chrome.runtime.onMessage.addListener to listen for events which I throw through the new CustomEvent(I think the plugin does already this with a different kind of website/plugin interaction). It would be nice to have an Event like this:

new CustomEvent('automa-start-workflow', {
  detail: {
    id: 'nbf6-qlwD-JCVptpnf9EF', // workflow id
    // custom data I want to pass to the workflow
    // maybe pass this as a variable? Or into the global data
    data: {
      keyword: 'Example Keyword'
    }
  }
}))

Which would start the workflow based on the id. I'm not sure what the best way would be to pass the data (maybe variable or global data).

To pass data to the global data or variable of the workflow, I guess the best way is by using the variables or globalData property inside the data object.

new CustomEvent('automa-start-workflow', {
  detail: {
    id: 'nbf6-qlwD-JCVptpnf9EF',
    data: {
      globalData: 'Example keyword' // Pass it to the workflow global data
      variables: {
        variableName: 'Example to keyword'
      } // Pass it to the workflow variables
    }
  }
}))

@Kholid060 Kholid060 added the enhancement New feature or request label Feb 26, 2022
@Kholid060 Kholid060 mentioned this issue Feb 27, 2022
@ZlydeTJ
Copy link
Author

ZlydeTJ commented Feb 28, 2022

@Kholid060 Wow it's already implemented that was quick! Thank you very much :)

I have yet to test it, but I think we can close this issue now.

@Kholid060
Copy link
Member

@Kholid060 Wow it's already implemented that was quick! Thank you very much :)

I have yet to test it, but I think we can close this issue now.

You're welcome, but to start to execute a workflow use the automa:execute-workflow event. E.g. new CustomEvent('automa:execute-workflow', {})

@ZlydeTJ
Copy link
Author

ZlydeTJ commented Feb 28, 2022

Thank you for the reminder. Once I've tested it through I let you know if there are any issues :)

@whwh656
Copy link

whwh656 commented Mar 1, 2022

Is your feature request related to a problem? Please describe. I want to use the automation from my own website to automate certain actions after I'm done using the website. So e.g.: It would be nice to start a search to an internal tool directly from my website when clicking a button with the related keyword, instead of copying it and then starting my actions. Especially since I have a lot of actions available. I currently have a Chrome-Plugin that does exactly this, however it would be more convenient to also use automa for this tasks.

Describe the solution you'd like In my plugin I use the chrome api chrome.runtime.onMessage.addListener to listen for events which I throw through the new CustomEvent(I think the plugin does already this with a different kind of website/plugin interaction). It would be nice to have an Event like this:

new CustomEvent('automa-start-workflow', {
  detail: {
    id: 'nbf6-qlwD-JCVptpnf9EF', // workflow id
    // custom data I want to pass to the workflow
    // maybe pass this as a variable? Or into the global data
    data: {
      keyword: 'Example Keyword'
    }
  }
}))

Which would start the workflow based on the id. I'm not sure what the best way would be to pass the data (maybe variable or global data).

Would this fit?

Alternatively what also would work is listening to all Button Browser events and have a certain trigger. For example if I were to post a comment on a website I would like to paste that comment also into a Google Docs Table. I could listen whenever a certain button is pressed a trigger a workflow.

This use-case is a bit broader since it also covers site that the workflow creator possible has no control over, however it would be a bit harder to pass data along, as this would first has to be scraped.

Can your tell me the name of chrome plugin , i want to use it, too

@ZlydeTJ
Copy link
Author

ZlydeTJ commented Mar 1, 2022

Hi @ whwh656,

sorry its for private use only. But I can share my workflow in the public library later, if that helps.

@whwh656
Copy link

whwh656 commented Mar 1, 2022

Hi @ whwh656,

sorry its for private use only. But I can share my workflow in the public library later, if that helps.

Thank you, your share workflow is also appappreciate

@ZlydeTJ
Copy link
Author

ZlydeTJ commented Mar 2, 2022

Hey @whwh656,

I build a small example here: https://www.automa.site/workflow/4Qjh_xUtW7Ow5WdB1YrF6

I've put the instruction on how to do use it in the description.

@whwh656
Copy link

whwh656 commented Mar 2, 2022

Hey @whwh656,

I build a small example here: https://www.automa.site/workflow/4Qjh_xUtW7Ow5WdB1YrF6

I've put the instruction on how to do use it in the description.

image

@ZlydeTJ
Copy link
Author

ZlydeTJ commented Mar 2, 2022

It's really simple actually.

You just select the workflow you want the ID from:
select-workflow
Now you can select the ID from the URL:
copy-id-from-url

@whwh656
Copy link

whwh656 commented Mar 2, 2022

thanks

@whwh656
Copy link

whwh656 commented Mar 3, 2022

version 1.2.1
exectute workflow have the same funcition of above
i 'm confused why write javascript code by the new CustomEvent in jsblock by myself
image

@ZlydeTJ
Copy link
Author

ZlydeTJ commented Mar 3, 2022

Hey @whwh656,

you would need it if you want to trigger a Workflow from any other source than the plugin itself. Usually you start a Workflow by clicking on it, or visiting a website or at a certain time or a keyboard shortcut.

However In my App I need to trigger a Workflow from my own Website via a Button. This button does things for my own website, however I want to execute a workflow directly after this, without triggering it via any other method. Also this allows me to pass data to the Workflow from my app.

@quoskin011
Copy link

Can you help me make a video tutorial?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants