Introducing GROQ-powered Webhooks

MonkeyLearn Pane

By Simeon Griggs

Send the contents of a Portable Text field to MonkeyLearn's API to extract insights with the power of Machine Learning!

sanity-plugin-monkeylearn-pane

Send the contents of Portable Text to MonkeyLearn's API to Extract insights with the power of Machine Learning!

Notes

  1. You will need a MonkeyLearn account (free!) in order to use this plugin
  2. By default the plugin will only display extraction results. To perform the below interactions back to your source Document, you will need to drop in your own Component in the Pane options.

Generating tags and patching document with machine learning

Installation

sanity install monkeylearn-pane

This is designed to be used as a Component inside of a View.

// ./src/deskStructure.js
import MonkeyLearnPane from 'sanity-plugin-monkeylearn-pane'

// ...all other list items

S.view
  .component(MonkeyLearnPane)
  .options({
    extractors: [`ex_vqBQ7V9B`],
    field: 'content',
    // Optional but recommended!
    // Use your own Component to display/interact with extractions
    displayComponent: <Report />,
  })
  .title('Analysis')

The .options() configuration works as follows:

  • extractors ([string], required) The ID's of the Text Extractors you want to produce reports for.
  • field (string, required) A dot-notated string from the document object to a field containing the Portable Text array.
  • displayComponent (React Component, optional) A custom Component for handling the report from each text extraction. You will need to BYO a Component that will accept the Document ID and Report as props, so that it can do something fancy like generating tag documents and sending a patch to the currently edited document.

Customising the output

The example shown above is included in this repo, see ReportTagCreator.js – this Component takes the report, generates a tag document if one does not already exists, and can send a patch back to the currently edited document in an array of references named tags.

License

MIT © Simeon Griggs See LICENSE

Install command

sanity install monkeylearn-pane

Contributor

Simeon Griggs

🇦🇺 in 🇬🇧 Solution Engineer @ Sanity

Simeon is located at Newcastle upon Tyne, UK
Visit Simeon Griggs's profile

Categorized in

Other plugins by author

Orderable Document List
- has 10 likes

Official(made by Sanity team)

Drag-and-drop Document Ordering without leaving the Editing surface

Simeon Griggs
Go to Orderable Document List

Iframe Pane

Display any URL in a View Pane, along with helpful buttons to Copy the URL or open in a new tab.

Simeon Griggs
Go to Iframe Pane

SEO Pane

Run yoast.js analysis on your front end, refreshing as you edit your Document, from inside a View Pane.

Simeon Griggs
Go to SEO Pane