Sharing Prizmo OCR to Drafts, Cloudier and Dropbox

Last week I created a version from a great workflow to grab a picture with Prizmo and send the OCR text to your Mac with Command-C, all I did was allowing device selection. Today we're going to play with Prizmo again, this time sharing our OCR among our apps and, while we're there, learning how its url scheme works and a few tricks for encoding complex actions.

If you haven't checked Prizmo's documentation, do so now, you'll find out it has two different outputs for your OCR text: pasteboard and url, the first will set the OCR to the clipboard and the latter will include it as the text parameter from your x-success action. Ok, this last one may sound a bit tricky.

The destination=url specification is actually quite flexible, however, limited to apps receiving a text parameter. As long as the app you return has such attribute, you can write it down in multiple ways, even omitting the parameter as a whole. The next two url would render into the same thing when called from Prizmo:

drafts://x-callback-url/create?
drafts://x-callback-url/create?text=

Now that this is behind us, we can start building an action to trigger Prizmo from Launch Center Pro with a selected language and send the output to Drafts:

OCR to Drafts:

prizmo://x-callback-url/captureText?language=[list:Choose Language|English=en|Português=pt]&destination=url&x-success={{drafts://x-callback-url/create?}}

Noticed how I skipped the text parameter? Next we gonna do the same thing, this time sharing to CloudApp via Cloudier1. There are multiple ways to upload data with this app, but one of the reasons I stuck with add?text is because it was the easiest way to get the shareable link in your clipboard afterwards.

OCR to Cloudier:

prizmo://x-callback-url/captureText?language=[list:Choose Language|English=en|Português=pt]&destination=url&x-success={{cloudier://x-callback-url/add?text=}}

Then let's wrap this up saving our text into a Dropbox file using LCP's own url scheme. I'll place this note in the path /Projects/Shared Notes and get the link in our clipboard using getlink=YES. I strongly suggest you check Launch Center Pro's documentation on its Dropbox actions as they have multiple exclusive parameters. Also, notice that we're not setting a name to our file as the default fallback is a data/time name, which is quite nice for a text you just want to quickly share.

OCR to Dropbox:

prizmo://x-callback-url/captureText?language=[list:Choose Language|English=en|Português=pt]&destination=url&x-success={{launchpro://dropbox/new?path=%2FProjects%2FShared%20Notes&getlink=YES}}

Noticed I manually encoded the path? Good, now we gonna get our hands dirty creating an action that will grab the OCR from Prizmo and get back to Launch Center Pro, where you'll be prompted to pick whatever app you would want to share and then launch it. Also, we gonna do this backwards, following an advice I received from Eric Pramono in my earlier days when encoding complex actions.

As you may have thought by now, we can't use the destination=url trick anymore because we're going to return to LCP with a url action, which doesn't support the text parameter. This time we're going to use the clipboard with destination=pasteboard and play with the [clipboard] parameter.

We have 3 possible outcomes for this whole action, all launched from Launch Center Pro:

drafts://x-callback-url/create?text=[clipboard]
cloudier://x-callback-url/add?text=[clipboard]
launchpro://dropbox/new?path=%2FProjects%2FShared%20Notes&getlink=YES&text=[clipboard]

Now we raise one level of encoding and set our url schemes into a [list]. Since all actions share the [clipboard] parameter, we're leaving it outside the list, also because you'll want to manually encode it.

launchpro://?url=[list:Choose Destination|Drafts=drafts://x-callback-url/create?text=|Cloudier=cloudier://x-callback-url/add?text=|Dropbox=launchpro://dropbox/new?path=%2FProjects%2FShared%20Notes&getlink=YES&text=]%5Bclipboard%5D

If you try running this action as an x-success parameter, it won't work, even wrapped in curly brackets. LCP will prompt you to select an item from the list before going to Prizmo. What we did there was creating the action that would use the clipboard, we need another layer of encoding to LCP launch itself and use the [list] at the right time. This means manually encoding the previous action. So open TextTool and do it, then add the launchpro://?url= prefix. You'll get something like this:

launchpro://?url=launchpro%3A%2F%2F%3Furl%3D%5Blist%3AChoose%20Destination%7CDrafts%3Ddrafts%3A%2F%2Fx-callback-url%2Fcreate%3Ftext%3D%7CCloudier%3Dcloudier%3A%2F%2Fx-callback-url%2Fadd%3Ftext%3D%7CDropbox%3Dlaunchpro%3A%2F%2Fdropbox%2Fnew%3Fpath%3D%252FProjects%252FShared%2520Notes%26getlink%3DYES%26text%3D%5D%255Bclipboard%255D

Our clipboard and the path from the Dropbox action have double encoding, everything else but the trigger url has single encoding. Now we have to wrap this in curly brackets to call it from Prizmo as a x-success parameter:

OCR Quick Share:

prizmo://x-callback-url/captureText?language=[list:Choose Language|English=en|Português=pt]&destination=pasteboard&x-success={{launchpro://?url=launchpro%3A%2F%2F%3Furl%3D%5Blist%3AChoose%20Destination%7CDrafts%3Ddrafts%3A%2F%2Fx-callback-url%2Fcreate%3Ftext%3D%7CCloudier%3Dcloudier%3A%2F%2Fx-callback-url%2Fadd%3Ftext%3D%7CDropbox%3Dlaunchpro%3A%2F%2Fdropbox%2Fnew%3Fpath%3D%252FProjects%252FShared%2520Notes%26getlink%3DYES%26text%3D%5D%255Bclipboard%255D}}

Reviewing how it works, Prizmo will receive the callback exactly as our x-success without the curly brackets, always keep in mind that for every bounce you lose one layer of encoding, that's the part you must pay attention to. Prizmo will launch LCP with a request to trigger itself and our [list] parameter, which already sends the chosen destination encoded, so we don't have to worry about that at least. Then Launch Center Pro launches itself with the chosen parameter, this time, only rendering the [clipboard] parameter and triggering the previously picked action.

Complicated? Well, not so much, just bloated and unintuitive. Building your actions backwards allow you to debug each step, then when you manually encode everything you can just forget about it and focus on the next floor.

Hope you learned something today.


  1. I was going to also include ClouDrop, however, I couldn't manage to get the text there, meanwhile Cloudier worked fine.