Automation - How to use triggers

With FeedHive's automation feature, we can build advanced, custom workflows that integrates with the many automation services out there.

In this article, we will learn how to set up a trigger.

What is a trigger?

A trigger is a URL that we can call in order to make FeedHive do something.
This is also known as an API endpoint - in FeedHive, we simply call this a Trigger URL.

When setting up a trigger, we can pre-configure FeedHive to take certain actions which will happen when we call the URL that FeedHive creates for us.

Let's take a look at which actions we can make FeedHive take.

Overview

Here is a short technical overview of triggers:

  • Requests to the trigger URL are sent using POST (recommended) or GET (for backwards compatibility)
  • A trigger URL can be triggered multiple times
  • For POST requests, data is sent in the request body as JSON
  • For GET requests, data is sent as query parameters

POST Method (Recommended)

Send a POST request with a JSON body containing your variables:

{
  "text": "Your post content here",
  "scheduled": "2024-01-15T10:00:00Z",
  "media_urls": "https://example.com/image1.jpg,https://example.com/image2.jpg",
  "title": "Post title",
  "custom_variable": "Custom value"
}

GET Method (Legacy Support)

For backwards compatibility, you can still use GET requests with query parameters:

https://api.feedhive.com/triggers/xxxxx?text=Your+post+content&scheduled=2024-01-15T10:00:00Z

A trigger may be configured to use a template. The template can include variables which may be accessed in the request body (POST) or as query parameters (GET).

Variables Reference

The following variables can be used when triggering a FeedHive automation:

Core Variables

VariableRequiredDescription
textOptional*The text content for the post. Required if no template is assigned to the trigger.
scheduledOptionalISO date string for when the post should be scheduled (e.g., "2024-01-15T10:00:00Z"). Only used with "Create & Publish" action.
media_urlsOptionalComma-separated list of media URLs to include in the post. Required for short-form content (Reels/Shorts).

Platform-Specific Variables

YouTube, Google My Business, and Pinterest

VariableRequiredDescription
titleOptionalThe title of the post. Used by YouTube, Google My Business, and Pinterest platforms.
linkOptionalA link to include with the post. Used by YouTube, Google My Business, and Pinterest platforms.

Google My Business Only

VariableRequiredDescription
couponCodeOptionalCoupon code for Google My Business posts.
startDateOptionalStart date for promotions (ISO date string).
endDateOptionalEnd date for promotions (ISO date string).
ctaOptionalCall-to-action button. Must be one of the supported CTA values.
termsAndConditionsOptionalTerms and conditions text for Google My Business posts.

Custom Template Variables

When using a template, you can define custom variables using the [[variable-name]] syntax in your template. These variables can then be passed in your trigger request:

{
  "text": "Check out this blog post!",
  "blog_title": "My Amazing Blog Post",
  "blog_url": "https://example.com/blog-post",
  "author_name": "John Doe"
}

*Note: The text parameter is required unless a template is assigned to the trigger that provides the post content.

Publish a draft

Let's set up a trigger to publish a draft that we have already created.

The first thing we'll do, is to create a new draft.
Let's do that by writing a post on the Compose page, but without scheduling it.

Next, let's go to the Automation page and create a new Trigger.

FeedHive will create a draft trigger for us.Under "Trigger URL", you can see that FeedHive already created the URL we will be using.

We want to pick Publish draft under the field "What happens when triggered?"
Then we click Select a draft under the field "Which draft should be published".

Once you have selected the draft you created, you will see a draft preview on the right side.
Finally, click "Save & Publish" to publish this trigger.

Now you can use the Trigger URL in any workflow service that allows sending POST requests (recommended) or GET requests (for backwards compatibility) - or you can incorporate it into a custom workflow that you have developed yourself.

Here is an example of how you can use it with Zapier using the POST method:

When configuring the webhook in Zapier:

  • Method: POST
  • Content Type: application/json
  • Request Body:
{
  "scheduled": "2024-01-15T10:00:00Z"
}

This will publish your draft at the specified time when a Zapier run is triggered by some event.

Create a draft

Next, let's set up a trigger to create a new draft from scratch.

A draft from scratch

Just like before, we go to the Automation page and create a new Trigger.
This time, we will pick Create draft under "What happens when triggered".

When we use this setting, we also get the option to pick a label and choose which social accounts should be selected for this draft.

Notice the Trigger URL that FeedHive created for you. You can now send POST requests to this URL with the post content and other variables.

You can pass the post text and other variables in the request body as JSON when using the POST method (recommended).

In the example above, we're using Zapier to react to a new to-do item created in the app Any.do. Configure the webhook with:

  • Method: POST
  • Content Type: application/json
  • Request Body:
{
  "text": "{{todo_title}}"
}

This will call the FeedHive trigger and use the title of the to-do item as the text of the draft.

Of course, this is just one example.
The options are almost endless.

A draft using a template

Sometimes adding the entire text through the text query parameter gets a bit tedious and repetitive.
Fortunately, FeedHive also allows you to use a post template, which can contain images, video and inline Trigger Variables as well.

Go the Assets → User Templates and let's create a new template.

Notice that we are using 3 Trigger Variables in this template: title-of-blogpost, excerpt-of-blogpost, and link-to-blogpost.

A variable can be anything you want, all you need to do is to wrap it in two square brackets: [[name-of-variable]].
When you're done, click Create to save this template.

Now, let's go back to the Automation page and set up a new trigger.
This time, we pick a template under the field "Pick a post template".

Notice that the Trigger URL is ready for use. The variables from your template can now be passed in the request body when using the POST method.

You can now use this trigger to automatically create a new draft every time a blog post is published.

For instance, we could use Zapier to listen to an RSS feed and automatically create a draft when a new blog post is live.

Configure the webhook with:

  • Method: POST
  • Content Type: application/json
  • Request Body:
{
  "title-of-blogpost": "{{rss_title}}",
  "excerpt-of-blogpost": "{{rss_description}}",
  "link-to-blogpost": "{{rss_link}}"
}

When this Zapier runs, a draft will be created in FeedHive, and all the variables will be substituted with the values from the request body.

Create and publish a post

Finally, you can also create and publish a post directly using a Trigger.
For this, pick Create & Publish post under the "What happens when triggered?" field.

This works in exactly the same way as with a draft.
The main difference is that this post will be created and then scheduled to go out immediately (or at the time specified in the scheduled variable).

Example POST request body:

{
  "text": "Check out our latest blog post!",
  "scheduled": "2024-01-15T14:30:00Z",
  "media_urls": "https://example.com/featured-image.jpg"
}

Other examples

Check out how Pete uses FeedHive Triggers and Make to sync draft posts between FeedHive and a Google Sheet document.

Line breaks, special characters and emojis

Using POST Method (Recommended)

When using the POST method with JSON, you can include line breaks, special characters, and emojis directly in your JSON without any encoding:

const requestData = {
  text: "Hello world! \n\nThis is a test post.\n\n😊",
  title: "My Post Title 🚀"
};
 
fetch('https://api.feedhive.com/triggers/xxxxx', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(requestData)
});

Using GET Method (Legacy)

If you're still using the GET method with query parameters, you need to URL encode the text before sending it to FeedHive:

const text = "Hello world! \n\nThis is a test post.\n\n😊";
const encodedText = encodeURIComponent(text);
 
const triggerURL = `https://api.feedhive.com/triggers/xxxxx?text=${encodedText}`;

FAQ‍

  • Can I use triggers with Zapier directly? Without having to use webhooks?
    Not at this moment. But we are working on integrations with a lot of services - Zapier, Airtable, Pabbly (just to name a few). These will be available as so-called "Recipes". For now, you can use Zapier's webhook action to send POST requests to your trigger URL.

  • Should I use POST or GET method?
    We recommend using the POST method with JSON in the request body as it's more flexible and doesn't have URL length limitations. The GET method is still supported for backwards compatibility.

  • Can I use FeedHive automation the other way around? Have FeedHive call a webhook when something happens, e.g. a post has published.
    Yes. These are called Notifications and work in reverse.