Content Studio integration overview
This page provides an overview of how to integrate Content Studio with your existing content workflow and how you can manage content generated using the Content Studio API.
Visit the Content Studio API page for more information about creating a content generation request using the GraphQL API.
Integration using webhooksLink copied!
One approach to integrate with Content Studio is to use webhooks. You can set up a webhook to notify your integration that content that you've generated using the Content Studio APIs is available. The content can then be reviewed as part of your approval flow.
When integrating with Content Studio using webhooks:
- Your application calls the Content Studio APIs to generate content.
- Content Studio processes these requests asynchronously.
- When a content generation job is complete, a webhook will be triggered and a webhook request, containing the completed job text in the webhook body, will be sent to the URL you specified.
- The generated content can then be reviewed within your app and subject to your approval workflow.
Setting up and viewing a webhookLink copied!
Currently a content generation complete webhook must be set up by Amplience support. Visit the content generation webhook section of the Amplience support service catalog or contact your Customer Success Manager.
In order to set up the webhook you will need to provide the following information:
- The hub name (eg "Documentation")
- The CMS hub id. This is the id of the hub within Content Studio that you will be using. You can find the CMS hub id using the Content Studio APIs.
- The webhook label. This is the friendly name that will be displayed in the webhook list in Dynamic Content.
- The webhook URL. This is the URL to which the webhook request will be sent when a content generation job is complete. Note this is the URL on which your integration listens for webhook requests and is part of your integration.
- Whether the webhook request should be sent as a POST or a GET.
- Whether to include any custom headers in the webhook request.
- An email address to be notified if the content generation has failed.
Viewing the webhook in Dynamic ContentLink copied!
If you have access to Dynamic Content, you can view webhook information by choosing "Webhooks" from the Development menu.
Once set up, the content generation complete webhook is shown in the list. Double click to open it.
Included in the webhook details is a webhook secret. The webhook secret is used to validate the authenticity of incoming webhook requests so you know the request is valid and coming from Amplience. The secret will also be provided to you when the webhook is set up.
Currently you can only view a content generation webhook in Dynamic Content and you cannot update its settings.
Viewing webhook deliveriesLink copied!
When you make a content generation request using the Content Studio API, the webhook will be triggered when the request is complete. You can find webhook deliveries in the activity log.
Note If you include multiple content generation requests in one API call, then the webhook will be invoked multiple times.
Example webhook requestLink copied!
You can open a webhook delivery to see the body of the request. The body includes the content that was generated in JSON format. You can then extract the content and start your approval process.
The body of a sample webhook request for a blog is shown below.
payload.id
is the job id for the content generation request. If you include multiple requests in the same API call, then each request will have its own job id and will be sent in a separate webhook delivery.
Note We recommend that you keep a record of the job id returned by a content generation request, so that when you receive the webhook request containing the job id, you can mark the job as complete.
payload.content.body
contains the generated content as a string of encoded JSON.
Note payload.content
will vary according to the template used. For example, when generating content using product description templates, the content will be in payload.content.description
.
payload.status
contains the status of the request:COMPLETE
,ERROR
orINSUFFICIENT_CREDITS
.
Webhook responseLink copied!
You should return a 200 OK response to a webhook request.
Integration using pollingLink copied!
Another integration approach is to use polling. A content generation request will return a job id. You can then use the job id to poll the status of the job until the generated content is returned in the response.
When integrating with Content Studio using the polling approach:
- Your integration will send a content generation request to the Content Studio API.
- For each successful request the API will return a job id.
- Your integration should poll the status of the content generation job using the job id until the job is complete.
- When the job is complete the generated content will be returned in the response.
- The generated content can then be reviewed within your app and subject to your approval workflow.