A "Post to Slack" Enrichment Service
This enrichment service posts a link to the Slack messaging service whenever a story is published. Before it posts the link, however, it needs to prompt the CUE user to enter a short name for the story, and the name of the Slack channel in which it is to be posted.
Here are the configuration settings for such a service:
enrichmentServices: - name: "Post to Slack" href: http://my-web-service-host/slack-service title: "Post to Slack" triggers: - name: after-save-state-published properties: {} mimeTypes: ["x-ece/story"]
This configuration specifies that any "story-type" content items
(content items that don't contain any binary fields such as video or
images, and aren't live events or Newsgate stories) will be posted
to the enrichment service at
http://
my-web-service-host/slack-service
when they are published.
When the Slack enrichment service receives such a content item, it
returns an HTTP 200
response with an
application/vnd.vizrt.payload+xml
body containing
a VDF payload document. The VDF document contains the prompts to be
displayed in the dialog, for example:
<vdf:payload xmlns:vdf="http://www.vizrt.com/types" model=”http://web-service-host/slack-channel-description.xml”> <vdf:field name=”slack-name”> <vdf:value>red-herring</vdf:value> </vdf:field> <vdf:field name=”channel”> <vdf:value>#sports</vdf:value> </vdf:field> </vdf:payload>
Note the following about this document:
-
The
vdf:payload
element'smodel
attribute must contain the URI of a VDF model document defining the structure of the payload. You must create this model document yourself and make it available somewhere (most likely on the same host as the enrichment service itself).The VDF model document for the example payload shown above might look like this:<model xmlns:vdf="http://www.vizrt.com/types"> <schema> <fielddef name="slack-name" label="Story name in Slack" xsdtype="string"/> <fielddef name="channel" label="Slack channel" xsdtype="string"/> </schema> </model>
For a description of the VDF model document format, see here.
-
The values in the fields are defaults. If you do not want to supply defaults to the fields in the form, you can omit the values.
When CUE receives the payload document, it looks up the referenced
model document and uses the information to construct and display a
dialog containing the specified fields. The user can then enter the
required values. When the user selects OK, CUE
will POST
the payload document (with any changes
made by the user) back to the enrichment service. The enrichment
service can then post the story to Slack and return HTTP
204
(No Content) to CUE, allowing CUE to complete the
operation that initiated the enrichment service call. Alternatively,
the enrichment service could return HTTP 200
(OK)
with a text/plain
Content-Type header in order
for CUE to display a message indicating that the story has been
posted to Slack. If the user selects Cancel
instead of OK, then nothing is sent to the
enrichment service and CUE just carries on and completes the
operation that initiated the enrichment service call.