Zapier integration
Context
The need
In the Creative Pro context, we need to integrate different third party tools such as:
- Trello/Asana/... for project management
- Slack/... for collaboration chat
While having different plugins could be useful for marketing visibility (such as a Slack in their marketplace) and for having more integration specific options, Zapier seems to fit perfectly to those needs.
What is Zapier
Zapier can chain different apps such as Gmail, Slack, Trello to achieve different task with input and output between. This chain is a Zap.
There are two main concepts:
- The triggers that are executed when new data have been fetched
- The actions that are executed after
Test Use cases
Custom trigger:
In the context of Creative Pro we would like to create Trello cards when new deliverable sets have been created:
- The card would be the name of the document
- It will contain some metadata in the description or the labels of the card
- It will contain the thumbnail blob(s) of the deliverable(s)
Custom Action:
Once a card would be created in Trello, we could for instance create a new deliverable.
Goals
- The trigger goal would be to listen to the Audit of Nuxeo and choose which events for which kind of documents we would use Zapier integration.
- The action goal is TBD. But we can actually post anything to a Nuxeo instance and even make a sort of generic Automation operations action but could be cumbersome to define the fields (we could just insert the JSON payload of the operation to post, but it's not very user friendly).
How it works
Authentication
Zapier can authenticate in many ways - we tested with basic Auth and OAuth with Nuxeo as a provider.
- Basic: nuxeo-brand-management-zapier/auth/basic.js
- OAuth: nuxeo-brand-management-zapier/auth/oauth.js
The choice needs to be set in nuxeo-brand-management-zapier/index.js(authentication attribute).
Polling vs Webhooks
We tested by polling the new document created via a Nuxeo page provider:
- Zapier is polling every 5 to 15 minutes (depending on the contract)
- The page provider needs to send a chronologically reverse order listing
- Once a new item has been created and sent back in the listing with a new id, Zapier will do the diff, detect and execute the Zap.
Another way we tested which is more recommended is to use webhooks:
- A static webhook with a unique URL for every events
- A subscription webhook with a dedicated URL for every single distinct event.
The fields
When you configure an app, you can have different fields:
- Static dropdown for instance with multi selection (here used for the events to select)
- Dynamic dropdown to select remotely to an entry for instance (here used for the project document selection)
- Etc....
The structure
├── README.md
├── auth
│ ├── basic.js
│ └── oauth.js
├── build
│ ├── build.zip
│ └── source.zip
├── creates - "the actions"
│ └── task.js - not implemented
├── index.js
├── package-lock.json
├── package.json
├── test
│ ├── authentication.js
│ └── project.js
└── triggers
├── AuditHook.js - "the audit trigger via hooks"
├── deliverableSet.js - "the deliverable set trigger via polling"
├── event.js - "the static dropdown for choosing events"
└── project.js - "the project dropdown for choosing a given project"
Tests
We haven't still focused on it - seems to be easy.
Environment variables
It is possible for instance to store all client id or secret of OAuth in Zapier env variables (https://github.com/zapier/zapier-platform-cli#environment)
Misc
- In order to be public, an app has to be used by 10 active users at least
- We can have maximum 5 triggers and 5 actions top (except if discussion for a specific contract)
- Here is the pricing: https://zapier.com/app/billing/plans
- For all of this we used Zapier CLI.
Demo
Polling demo: http://recordit.co/m4VnNiwg97
Creative Pro - TODO
For a real implementation with WebHooks:
- We need to configure oauth for each tenants during their creation (with Nuxeo as a provider)
- We need to update the deployment-fragment for forwarding correctly all URLs in the tomcat filters
- We need to use the notification service for posting all related events to Zapier
- We need to update the extended fields of the Audit for having more information about the related document such as the title...
- We need to store the principal, the chosen events and the target url to post to.
- When posting the audit entries to Zapier, we need to handle the response:
Example of URL to post to: https://hooks.zapier.com/hooks/standard/3397485/797e85ea68cf4214848b8c561bdde2e8/
Example of each hook call response:
{
"status": "success",
"attempt": "5b928464-2d3f-408a-9e0f-9183d8c12a60",
"id": "72f79cf9-bdcd-4d47-9dce-8e8fd66252a1",
"request_id": "5b928464-2d3f-408a-9e0f-9183d8c12a60"
}
- Testing webhooks with actions (Automation API)
- Deciding which parameters to suggest