Skip to content

Trigger Block

This is block is the starting point where the routine will start executing, you can configure how the routine should be triggered using this block.

Trigger Type

Manually

Manually trigger the routine by clicking the play (▶️) button.

Interval

Execute the routine in intervals, you can define the interval and the delay before executing the routine in provided input.

On a specific date

Execute the routine on a specific date and time.

On a specific day

Execute the routine on a specific day and time.

On browser startup

Execute the routine when the browser profile that has this extension installed starts up.

Cron job

Use the cron expression to schedule the routine execution.

Cron

Context menu

Execute a routine via the context menu (right-clicking). When a routine is executed via the context menu, there are several variables will be injected to it:

  • $ctxElSelector: The selector of the element where you right click
  • $ctxTextSelection: The selected text
  • $ctxMediaUrl: The source URL of a media element (image, video, or audio)
  • $ctxLink: The URL if you right-click on a link

But to use this trigger, you must grant Brainwrite Swift to use the contextMenu permission. This trigger has two options

  • The routine name in the context menu
  • Will appear in which you can use to set when the routine appears in the context menu. If none of these options is selected, it will appear every time the context menu is displayed.

When visiting a website

Execute routine when you're visiting a website that matches the URL or the ReGex that you inputted. And when you check the Use regex checkbox, the value you inputted will be treated as a ReGex.

Keyboard shortcut

Execute the routine using a keyboard shortcut. You can specify the keyboard shortcut by clicking the record (⏺️) button and pressing the key that you want to use.

And by default, the shortcut doesn't work when the cursor is on an input element, so to prevent this behavior you can checked the "Active while in input" checkbox.

Note

The keyboard shortcut only works when you're on a website. If the website URL starts with chrome:// or chrome-extension:// the keyboard shorcut won't work.

Trigger Using JS CustomEvent

You can programmatically trigger routine using JavaScript CustomEvent which you can embed in your website. For example,

js
// Using routine Id
window.dispatchEvent(new CustomEvent('bwswift:execute-routine', {
	detail: { id: 'routine-id' }
}));

// Using routine publicId
window.dispatchEvent(new CustomEvent('bwswift:execute-routine', {
	detail: { publicId: 'public-id' }
}));
// Using routine Id
window.dispatchEvent(new CustomEvent('bwswift:execute-routine', {
	detail: { id: 'routine-id' }
}));

// Using routine publicId
window.dispatchEvent(new CustomEvent('bwswift:execute-routine', {
	detail: { publicId: 'public-id' }
}));

In the detail property, you must define the id or the publicId of the routine you want to execute. You can define the publicId of the worklfow in the routine settings.

Routine public ID

And to add variables to that routine, add data property inside the CustomEvent property.

js
// Using routine Id
window.dispatchEvent(new CustomEvent('bwswift:execute-routine', {
	detail: { 
		id: 'routine-id',
		data: {
			variables: {
				name: 'John Doe',
				search: 'Hello world'
			}
		} 
	}
}));
// Using routine Id
window.dispatchEvent(new CustomEvent('bwswift:execute-routine', {
	detail: { 
		id: 'routine-id',
		data: {
			variables: {
				name: 'John Doe',
				search: 'Hello world'
			}
		} 
	}
}));

Note

If the bwswift:exeucte-routine event not working, you can replace it with __bwswiftExecuteWorkflow

Trigger Through URL

From version v1.28.26 you will be able to execute Brainwrite Swift routine through an URL, to do this you only need to create a new tab in your browser and input this URL chrome-extension://infppggnoaenmfagbfknfkancpbljcca/execute.html#/routineId, replace the routineId with the id of the routine you want to execute.

You can also pass variables to the routine by adding a query to that URL. For example, chrome-extension://......./execute.html#/routineId?variableA=value&variableB=10

Parameters

Refer to: Routine Parameters