actions
When your views yields results, what TriggerKit performs are actions. These are functions that take in results and perform things like send slack messages, perform SQL operations, make API calls, etc.
You can either use some of our built-in actions or build your own!
Built In Actions:
run_sql
run_sql (data)
send_slack_message
send_slack_message (data)
Use the returned data to send slack messages. This could be used for creating alerts for data issues, reporting on metrics, etc.
Make Your Own Actions
It is simple to make your own actions. All you have to do is make a function that takes in a List of Dicts and register it with the system
Example action:
```python from triggerkit import register
@register(‘My Action’,‘Does something I want’) def my_action( data: List[Dict], # List of results from the view context: Dict[str, Any], # Shared context between actions config: Dict[str, Any], # Config for the action - Passes job-specific parameters (e.g. thresholds, channel IDs) job_name: str, # (Optional) Name of the job - Helpful for logging, auditing, and debugging run_id: str, # (Optional) Unqiue ID of the run - Useful for traceability in logs, alerts, and audits **kwargs ) -> Dict[str, Any]: …
register
register (name:str, description:Optional[str]=None, overwrite:bool=False)
*Register your function as an action in the global registry.
Args:
• name: Descriptive name for your action
• description: Optional description of what the action does
Raises:
• ValueError: If an action with the same name already exists*
get_info
get_info (name:str)
Get detailed information about a specific action.
list_available
list_available ()
List all registered actions with their descriptions.
run
run (action_name:str, data:List[Dict[str,Any]], context:Optional[Dict[str,Any]]=None, config:Optional[Dict[str,Any]]=None, job_name:Optional[str]=None, dry_run:Optional[bool]=False)
*Run a registered action with the provided data.
Args:
• action_name: Name of the registered action
• data: Data to pass to the action
Returns: Result of the action*