Monok News Logo

Integration

There are multiple ways of integrating with established publishing tools. Monok allows the user to automatically generate a draft from the chosen article, by pushing the content to their system of choice. You can also automatically publish from Monok directly to your WordPress website, custom backend system or to your teams slack channel.

WordPress

A WordPress plugin is available that allows you to push out any article of your choice to your WordPress admin as a new draft. Once the plugin is installed, a settings page will appear on your WordPress admin, where you can choose the default category, resolution of the featured image and other important settings.

  • Automatic category/section matching
  • Automatic featured image setup
  • Choose post type
  • Choose the default author
  • Quotes are styled according to your theme
  • All embedded content is pushed (Youtube Video, Instagram Post, Twitter Post etc)
  • Choose the resolution of photos
  • Automatic interlinking to other posts on your site
  • Keeping track of what your own team writes so to avoid duplicate

Installation

  1. Download the WordPress plugin from your settings page and install it in your WordPress admin for the website you wish to integrate with, it is important to remember that each user has a unique and private plugin, that contains your API key and should not be shared with others.
  2. Go to your monok profile and check if your website has synced with Monok; if not, add the URL of your WordPress admin to your list of WordPress websites.

That’s it, you can then start pushing out articles by opening up an article, pressing push to WordPress and choosing your WordPress URL.

API

The API endpoints are for our business customers to receive and store generated content. The WordPress plugin uses this API and we recommend our clients to replicate the behavior or modify the plugin to access the same features we offer across the plugin.

Receive articles from Monok

Any article can be pushed to your backend-system from our frontend using our Push Article API. It’s the easiest way to integrate with Monok to your custom CMS website or native application. All you need to do is open up an API endpoint in your own backend, the endpoint should also take a token to verify the request is coming from your Monok account, that token is by default your own API-key. You can specify a different API-key in your Feed settings page on Monok when adding the API integration (see below).

Type: POST-Request Example: https://www.myOwnWebsite.com/my/api/path

Monok will use this method to push out an article to your backend

$ curl -XPOST -i https://www.myOwnWebsite.com/my/api/path' 
-H "Content-Type: application/json" 
-H "token: [ API-Key ]"

Add the endpoint as a new API integration in your Feed settings page on Monok.
When adding an endpoint, three input fields will appear where you specify the following:
API-endpoint – url for your api endpoint
Access token – custom api key or leave blank to use your monok account api key
Title – name of this integration

You will then be able to push your articles from the dropdown menu of any article as such:

This is also how articles are pushed automatically to your website once a human edit is complete and submitted.

Post Body

You will receive articles as a JSON-object with the following fields

titleStringThe title of the article
shortTitleStringA shorter title used for meta tags, the Monok plugin uses this to pre-fill your Yoast/RankMath plugin
descriptionStringA description of the article for meta tags, the Monok plugin uses this to pre-fill your Yoast/RankMath plugin
contentStringThe article as HTML to be rendered by your CMS
textStringThe article as markdown
slugStringA slug generated from the title, for URL generation, the Monok plugin uses this to pre-fill your Yoast/RankMath plugin
idStringA unique ID for the article, use monok.com/puff/ID to access the article from Monok
thumbImageDataStringThe featured image as a base64 encoding of a PNG image
thumbImageDescriptionStringThe featured image description
languageStringThe language of the article in ISO 639-1 standard, such as “de” for German. For some languages this is followed by an ISO 3166-1 Alpha-2 standard with a dash (-) as seperator. British English is thus “en-gb”
typeString“blog” or “news”
keywords[String]Array of keywords
tags[String]Array of tags
vfImageObjectA JSON object with detailed information about the featured image
sectionsStringName of the category for article

Article Text Format

The article text is formatted using markdown with occasional JSON injections representing widgets, that is: Embedded X/Tweets, Instagram posts, YouTube videos or Quotes. Here’s an example of how a post from X/Twitter can look like injected into an article.

{
    "data":
    [
        {
            "name": "Phil Spencer",
            "text": "Had good calls this week with leaders at Sony. I confirmed our intent to honor all existing agreements upon acquisition of Activision Blizzard and our desire to keep Call of Duty on PlayStation. Sony is an important part of our industry, and we value our relationship.January 20, 2022"
        }
    ],
    "id": "1484273335139651585",
    "type": "twitter",
    "url": "https://twitter.com/XboxP3/status/1484273335139651585",
    "username": "XboxP3"
}

We recommend splitting the article text at every newline (\n) and validating whether the item is markdown text or a JSON-object.Depending on which it is, you can compile the markdown to HTML and the JSON-object to your own HTML compiler.

In WordPress for instance, markdown should be compiled to HTML and JSON should be evaluated, for X/Twitter objects and YouTube object, inserting the URL field is sufficient for WordPress to understand that this is an embedded tweet or YouTube video, whilst for Instagram posts, you will need to insert an iFrame directed to the URL.

We recommend using Drawdown by Adam Legget, as it is small (~4 KB), and compiles Monok articles well, into HTML.

For most use-cases it’s easier to just use the HTML field from the JSON-body for your Strapi or WordPress integration, this field provides you with the whole article, as a WordPress ready HTML rendition.

Featured Image

An article JSON also comes with a thumbnail URL, this is the easiest way to download the visual focus object (featured image) as a photo.

We however strongly recommend using the “thumbImageData” field in the JSON deliverable. This is a base64 encoding of a PNG photo. You should always try to favor this photo over any thumbnail url or visual focus object. This is the whole photo provided to you for storing in your image database, as a PNG file, compressed, based on your preferences as configured in the Monok subscription feed settings.

Many servers limit the amount of data you can send to them. When a thumbImageData field is sent, it can exceed that limit (If high quality is chosen in the feed settings), thus yielding a 413 Payload Too Large error. To resolve this issue, make sure your Nginx value for client_max_body_size is larger than 5mb.

Expose website info

Monok fetches information about your website to enhance the generation and delivery of articles. Implement this feature to ensure you get the same results as using the plugin.

  • Incorporate website branding such as logotype, primary color etc in images
  • Expose post types for automatic post type setting
  • Expose post tags for automatic tagging
  • Expose available categories for better category selection

Open up an endpoint in your backend for GET-requests, Monok will fetch the information as such:

$ curl -XGET -i https://www.myOwnWebsite.com/wp-json/monok/v1/info?apikey=YOUR_API_KEY

Send Back Data

When an article is published on your system, you have the option to send information about the article back to Monok. The are several benefits to doing this.

  1. You will double-link the articles so you may access the published article from Monok
  2. When new articles are published, they will include links to previously published articles if you’ve activated Interlinking (on by default)

The target URL is /api/v1/linkback, it takes a POST request with the following JSON body:

{
    "puff":
    {
        "title": "Governor Greg Abbott on Texas repercussion of severe winter weather",
        "article": "Governor Greg Abbott to be briefed on the effects of heavy winter weather on Texas at the Alternate State Operations Center [...]"
    },
    "id": "1t8e9-governor-greg-abbott-on-texas-repercussion-of-severe-winter-weather",
    "url": "https://www.natureclimatechange.com/governor-greg-abbott-on-texas-repercussion-of-severe-winter-weather/",
    "source": "natureclimatechange.com",
    "userId": "natureclimatechange.com-WP",
    "thumbnail": "https://www.natureclimatechange.com/wp-content/uploads/2022/02/3187562f6efb196adeb207e62f392f44_testcollage.png"
}

The “id” refers to the Monok article Id, whilst the userId is just a unique identifier, we propose the domain name plus an identifier for your website, WP for WordPress for instance or Strapi for your Strapi-based CMS.

Troubleshooting

Many servers limit the amount of data you can send to them. When a thumbImageData field is sent, it can exceed that limit, thus yielding a 413 Payload Too Large error. To resolve this issue, make sure your Nginx value for client_max_body_size is larger than 5mb.

In some cases, the website has limited POST and GET calls by restriction of endpoints through Nginx. To resolve this, open up the following endpoint:

website.com/wp-json/monok/*

The wildcard is there because there are two paths, Nginx configurations understand wildcards

If your Nginx setup resitricts IP’s, open it up for this address: 51.15.93.77

Embedding content such as tweets is easy with WordPress. By default Monok inserts the url for a youtube or a tweet as new line in the text. If you’ve disabled this feature on WordPress, you can instead embed as HTML or as a shortcode.

Our shortcode for twitter is:

 [twitter url=”…”]