This topic was automatically generated from Slack. You can find the original thread here.
From inside the workflow, how can I trigger the deactivate webhook?
This topic was automatically generated from Slack. You can find the original thread here.
From inside the workflow, how can I trigger the deactivate webhook?
The deactivate hook in Pipedream components (especially sources) is automatically invoked by Pipedream when a source is updated or deleted. It is not designed to be triggered manually from within a workflow or code step. If you want to trigger the logic inside a deactivate hook manually, you would need to refactor that logic into a function that can be called both from the deactivate hook and from a workflow step. However, the actual deactivate() lifecycle hook itself is only called by Pipedream’s platform during component lifecycle events (like deletion or update), not by user code. Summary: - You cannot directly trigger the deactivate webhook from inside a workflow. - The deactivate() hook is only invoked automatically by Pipedream when a source is updated or deleted. - If you need to run the same logic elsewhere, refactor it into a reusable function. For more details, see the Pipedream component contributing docs. If you have a specific use case or need help refactoring your code, let me know!
I created a custom source and can successfully call the activate webhook function, but I’d like to know how to trigger the deactivate webhook function. I’m testing the source.
To trigger the deactivate webhook (the deactivate() hook) in your custom Pipedream source, you cannot call it manually from within your workflow or source code. The deactivate() hook is automatically invoked by Pipedream when: - The source is deleted - The source is updated (for example, when you change props or redeploy) This is confirmed in the Pipedream component contributing docs: > The deactivate() hook is automatically invoked by Pipedream when a source is updated or deleted. A common use case for the deactivate hook is to automatically delete a webhook subscription when a component is deleted, but you can run any Node.js code within the deactivate hook. ### How to test the deactivate hook To test your deactivate logic: 1. Delete the source in the Pipedream UI. This will trigger the deactivate() hook. 2. Update the source (e.g., change a prop or redeploy). This will also trigger the deactivate() hook. You can add logging or other side effects in your deactivate() method to confirm it runs. #### Example export default defineComponent({ // ...props and other hooks... async deactivate() { // Your cleanup logic here console.log("Deactivating source and cleaning up webhooks"); }, }); Summary: You cannot trigger deactivate() manually from a workflow or code step. It is only called by Pipedream when the source is updated or deleted. To test it, delete or update your source in the UI. If you need to run the same logic elsewhere, refactor it into a function you can call from both deactivate() and other parts of your code.