Cloudinary's API's provide some great capibilities such as auto tagging.
Sometimes developers want to expand on that by calling other Third Party APIS such as IBM Watson.
In this example we'll take an asset previously uploaded to cloudinary and use IBM Watson services to classify the image to find out what's in the image and then combine the image metadata into a JSON payload, and save that payload back to Cloudinary as a Static JSON resource.
This simple pattern allows for caching the meta data within a static file.
This scenerio might be used versus calling Watson API's each time you want to retrieve the additional meta data.
We're using Auth0 Webtasks to host this Function as a Service (FAAS) example:
Sign up for IBM Bluemix and Cloudinary. Create an account with Webtask.io
Add your cloudinary and IBM Watson Credentials as secrets key values:
Cloudinary Credentials: cloud_name api_key api_secret
IBM Watson API Key: watson_api_key
Install the webtask cli: https://webtask.io/cli
Create your webtask: (from our URL)
wt create https://gist.githubusercontent.com/dzeitman/a029fe8890bafd05a0320e4305369217/raw/9d919bf9a0de9640e6092c1a56e79ea2b455a073/cloudinary-watson.js --name cloudinary-watson-classify --secret watson_api_key=<your-watson-key> --secret cloud_name=<your-cloudname> --secret api_key=<your-apikey> --secret api_secret=<your-api-secret>
Edit and run your webtask:
wt edit cloudinary-watson-classify
Or from the browser: (Where public_id is a previously uploaded image) https://wt-1f717bba0ab14ce48591a3520bd159b5-0.run.webtask.io/cloudinary-watson-classify?public_id=studio-talk&save_json=true
FAAS Function Workflow: public_id --> Classify --> UpdateCloudinary --> Save
Example Static JSON Output: http://res.cloudinary.com/de-demo/raw/upload/v1509023864/studio-talk.json
More about Webtask: Getting Started with WebTask: https://webtask.io/docs/101