Create a custom connector in the Power Platform – The WordPress example

Have you tried to create a custom connector in the Power Platform? As I was getting annoyed with the limitations of the existing WordPress connector here a full example.

Step 1 – Find an API for your connector

In my case I found that the existing connector for WordPress was just not good enough. Just a few actions that would give me hardly anything, didn’t do the trick for me.

I quite quickly ended up on the REST API documentation supplied by WordPress and there is so much more than just a few action currently offered by the connector

WordPress even offers an API console where you can test the endpoints to see how they work.

So that is step 1 complete. we have a list of endpoint that we can use within the connector.

Step 2 – Figure out the authentication

Now we need to figure out how to connect to that API. Similar to OAuth in Azure we will need to have an app registration. WordPress has made this easy too.

Within the My Applications section of the Developers documentation you can create an app.

Create a custom connector in the Power Platform - The WordPress example Microsoft Power Apps, Microsoft Power Automate image
Create a custom connector in the Power Platform - The WordPress example Microsoft Power Apps, Microsoft Power Automate image 1

Once you’ve created the app, you will be given the OAuth information that you will need as part of the connector configuration.

Step 3 – Get yourself a coffee or tea

In general the Authentication is the toughest part to sort out (not the most work, but definitely the hardest part).

Step 4 – Create the basic custom connector

Within Power Automate ( but you could also use the Power Apps screens if you prefer purple above blue) you can find the Custom Connectors section in the left hand navigation hidden under Data.

In there Create a new custom connector and select the create from blank.

Create a custom connector in the Power Platform - The WordPress example Microsoft Power Apps, Microsoft Power Automate image 3

Now we will have to supply the first parts of the custom connector. Add a icon as you want to see this within your flows. This icon will help you identify your connector.

Custom Connector General

Then the only other important part is the host. The host is your base part of the url that is used by every action in your connector. Looking at the documentation all my endpoints will look like this

https://public-api.wordpress.com/rest/v1.1/sites/$site

So the host is public-api.wordpress.com.

This is an important part to notice! This REST API will work for sites hosted on wordpress.com only. Phew, SharePains.com is hosted on wordpress.com.

The Security tab is the next section to complete. We will now need all the details that our app supplied to us earlier.

Create a custom connector in the Power Platform - The WordPress example Microsoft Power Apps, Microsoft Power Automate image 4

Also noticed that once you have completed the above you will be given the Redirect URL. This one you will need to use within your app registration.

Step 5 – Add the actions

We now have the base connector ready. The authentication is in place, we just need to create all the actions.

I’m going to start by adding an action to get site details. We already know the endpoint to use.

https://public-api.wordpress.com/rest/v1.1/sites/$site

In the first section of the action confgiration we can supply the Summary. This is how the action will appear within Power Automate. Then a description, this will help your user to understand what the action does. And finally an Operation Id which is a unique identifier for your action within your connector.

Create a custom connector in the Power Platform - The WordPress example Microsoft Power Apps, Microsoft Power Automate image 6

Then Visibility, you can set to either none, advanced, internal or important. Depending on what you choose the options will be hidden or visible to your users. I would almost always select important.

Now we get to the request part. to make Power Automate understand that we want a parameter for the site, we will need to create a token. This can be done by adding {site} to the URL rather than the $site suggested by WordPress.

https://public-api.wordpress.com/rest/v1.1/sites/{site}
Create a custom connector in the Power Platform - The WordPress example Microsoft Power Apps, Microsoft Power Automate image 7

This will create a Path property matching our {site} token. Potentially you could give tokens a default value. But in this case that isn’t needed.

If we were now run a flow with the action that we created (you will have to update the connector first, so don’t try this yet!), you would find that you can only selct body from the Dynamic content.

Create a custom connector in the Power Platform - The WordPress example Microsoft Power Apps, Microsoft Power Automate image 8

To solve this problem we will need to run the flow and configure a default response

Create a custom connector in the Power Platform - The WordPress example Microsoft Power Apps, Microsoft Power Automate image 9

In the form that is then presented you can import a sample output and you will see that when endpoints give you a lot of data back you might want to adjust the sample a bit. Unless you like Dynamic content to be flooded, leave out the properties that you find less important.

Create a custom connector in the Power Platform - The WordPress example Microsoft Power Apps, Microsoft Power Automate image 10

As a final part of the action creation process check the validation. Unless you see the green tick you will probably find that there is somethign wrong.

Create a custom connector in the Power Platform - The WordPress example Microsoft Power Apps, Microsoft Power Automate image 11

Step 6 – Update the connector

Now that we have some actions configured hit the update connector and your flow is ready to run:

Create a custom connector in the Power Platform - The WordPress example Microsoft Power Apps, Microsoft Power Automate image 12

Step 7 – Test the connector steps

You can test each action within the connector configuration screens, but often I just create a flow to test my connector. Especially when I want to retest my connector it is just easier to create a flow with all actions from my connector included.

Create a custom connector in the Power Platform - The WordPress example Microsoft Power Apps, Microsoft Power Automate image 13

And as I run my flow I’m getting the results as I expect.

Create a custom connector in the Power Platform - The WordPress example Microsoft Power Apps, Microsoft Power Automate image 14

Step 8 – Enjoy telling people about your custom connector

This is the final step in this post. I could just keep this custom connector to myself but why not submit this as a custom connector so that other users of Power Automate and Power Apps can make use of it too?

You can do this through the Independent Publisher program. Once I’ve got the full WordPress API implemented expect to see this new connector arrive.

Continue Reading Pieter Veenstra’s Article on their blog

Create a custom connector in the Power Platform – The WordPress example

Have you tried to create a custom connector in the Power Platform? As I was getting annoyed with the limitations of the existing WordPress connector here a full example. In my case I found that the existing connector for WordPress was just not good enough.

Blog Syndicated with Pieter Veenstra’s Permission

Author: Pieter Veenstra

Share This Post On
Share via
Copy link
Powered by Social Snap