Importing content from Google Docs to eZ Platform
Content creation happens a variety of places. Some prefer drafting on paper, others outline content in a simple text file while others prefer doing all of their editorial work in their online content management system. eZ Platform offers robust content creation capabilities, but we acknowledge that we need to be flexible and let users work with their preferred tools.
Online office suites such as Google Docs, Office 365 and Zoho are widely deployed by companies, big and small. These tools allow people to collaborate on a single document or spreadsheet in real time. Many use these tools to support their creative process and to draft up ideas and gather content before eventually wrapping it up to a finished article.
In addition to user interfaces, online applications like Google Docs and Microsoft OneNote also have extensive APIs that can be used to interact with the data stored in them. By combining these with the eZ Platform Digital Experience Platform (DXP) APIs, developers can integrate the two systems to provide an ideal user experience for content editors in an organization.
For example, initial content creation and resource gathering could happen in a shared Google Docs document. Once the initial stage is done, the document can be transferred onwards in an editorial workflow process in eZ Platform. This will allow the team to harness the power of collaborative editing as well as editorial control over the publishing process.
An overview of the importing process
Every SaaS provider should endeavor to make it as easy as possible to interface with their products. Google with their Docs product is certainly doing a good job, as they've got extensive documentation and examples on the use of their APIs. They also provide client libraries in JavaScript, PHP, Python, Ruby and other popular programming languages.
eZ Platform is written in object-oriented PHP, so the PHP library is our natural choice. This library handles the heavy lifting for authentication and communication between our application and the cloud infrastructure running the Google Docs service. There is also a bundle for the Symfony framework for the PHP library which could ease integration in our case.
Integrations themselves are often quite a mechanical task, especially with good tooling. The main challenge comes from mapping the domain models of two different systems. For text documents, Google provides good documentation of their internal data model, including the definitions of objects and their relationships: Structure of a Google Docs document.
Thankfully matching the two domains in this case is straightforward. Unlike a vast majority of Web Content Management Systems (WCMS), the eZ Platform RichText field type stores it in the content repository as structured documents instead of HTML blobs. Translating the Google Docs domain model to our extended DocBook syntax is relatively straightforward.
The import process itself is done by making remote calls to the Google Docs API using the google/apiclient client library and using our public PHP API, REST or GraphQL APIs over HTTP. This is the mechanical process of matching input to internal data model, creating and persisting objects to the database and so forth. Triggering the import process itself can be executed using a webhook, a CLI command or a controller action in the MVC model.
It is worth noting that for the richtext field type you need to input data in either the native XML DocBook format or the XHTML5 edit format used by the richtext editor in the administration interface. Many prefer the latter since it allows working with familiar HTML markup, which is automatically converted to valid DocBook upon storage. The end result is identical - the choice is purely up to the input format preferred by the development team.
Once the import process has completed the end result is a native object in the eZ Platform content repository. The two objects have effectively diverged, but you can still link the two for performing updates. You can do this by storing the Google Docs ID to the remote ID metadata field in the eZ Platform storage model and writing logic for object updates.
Video demo and sample code
The above outline can be helpful to get an overview, but a short video and some functional sample code makes it easier to understand the process:
The source code for the CLI command prototype used in the demo is available on GitHub (github.com/janit/ezplatform-google-docs-demo). Note that it is for the upcoming version 3.0 of eZ Platform which uses the Symfony 4 structure. The content API usage is identical to the latest Long Term Supported release (2.5), so if you're looking to integrate with Google Docs today, you can use it as a guideline and read our technical documentation for details.
We believe the ability to integrate external systems is key feature that every DXP should have. Our open APIs and the use of the industry standard Symfony framework enable developers to create advanced integrations without compromise.
Considerations for Creating Rich Customer Experiences
DXP eBook
If you are struggling with your B2B digital transformation efforts, why not reach out to us to discuss your project. Feel free to download and read Ibexa's eBook on Digital Experience Platforms and the four considerations for creating exceptional customer experiences.