Refresh

This website developer.automatorplugin.com/create-a-custom-automator-integration/ is currently offline. Cloudflare's Always Online™ shows a snapshot of this web page from the Internet Archive's Wayback Machine. To check for the live version, click Refresh.

skip to Main Content

Creating an Uncanny Automator integration

Custom Triggers & Actions
1. Creating an Uncanny Automator integration
2. Adding a Trigger to Uncanny Automator
3. Adding an Action to Uncanny Automator
4. Adding a Condition to Uncanny Automator Pro
5. Adding a Settings Page for an App Integration
6. Uncanny Automator terminology

Before we dive into developing a custom integration for Automator, please check out the terminology article to get familiar with how Automator is structured and how we call its key parts.

Building a custom Automator Integration

In this section we will build a custom integration for Automator. This integration will have a trigger, an action, one condition, some tokens and a settings page.

Creating the plugin


TLDR, you can also download the plugin we are going to build from our GitHub repository. Or get this particular file from here.


First, let’s create a new folder /wp-content/plugins/automator-sample-integration-plugin and an automator-sample-integration-plugin.php file in it:

<?php

/**
 * Plugin Name: Automator Sample Integration
 */

Then, hook a custom function to the automator_add_integration action:

add_action( 'automator_add_integration', 'sample_integration_load_files' );

function sample_integration_load_files() {

}

This way your integration will only load if Automator plugin is active.

Before we load any files, we need to check that Automator is up to date and has the required Integration Framework class.

function sample_integration_load_files() {

    // If this class doesn't exist, Uncanny Automator plugin needs to be updated.
    if ( ! class_exists( '\Uncanny_Automator\Integration' ) ) {
		return;
	}
}

Now let’s load a new file that will have the integration class:

function sample_integration_load_files() {

	// If this class doesn't exist, Uncanny Automator plugin needs to be updated.
	if ( ! class_exists( '\Uncanny_Automator\Integration' ) ) {
		return;
	}

	require_once 'sample-integration.php';
	new Sample_Integration();
}

It’s always a good idea to use autoloading, but we will leave it out of the scope of this tutorial.

Let’s create the sample-integration.php file:

<?php

class Sample_Integration extends \Uncanny_Automator\Integration {
	
	protected function setup() {
		$this->set_integration( 'SAMPLE_INTEGRATION' );
		$this->set_name( 'Automator Sample Integration' );
		$this->set_icon_url( plugin_dir_url( __FILE__ ) . 'img/sample-icon.svg' );
	}
}

Extend the \Uncanny_Automator\Integration class and define the setup method.

Use the class methods to set the integration ID, name, icon and icon url. In this case we have placed a dummy icon in /img/sample-icon.svg

And that’s it! Your integration is now registered with Automator, but you won’t be able to see it anywhere yet because it has no Actions or Triggers. Let’s move on and create them!

Back To Top