Operational Intelligence for MFT

Accessing Syncplicity content with Alexa, Part 2

accessing Syncplicity content files

My prior experiment with Alexa, successfully allowed me to access my Syncplicity files from any Amazon Echo device. Using a few Syncplicity API calls and some basic conversation design, I was able to have Alexa navigate my folders and read back to me the various files contained there.

Now it was time to go boldly where no digital assistant had gone before. I was determined to have Alexa actually play and read my files to me!

Music to my ears?

Anyone with an Amazon Echo device knows that Alexa can play any song you ask for, provided that Amazon already has that song in their music library. So, in theory, I should be able to have Alexa play any audio file that I have in Syncplicity.

A quick look at the Amazon Developer Portal shows that an Alexa Skill can stream audio from any URL. That’s great!

But, wait…

Syncplicity’s APIs provide a way to download files and Alexa doesn’t have anywhere to download to! To have Alexa play a file, I need to provide a streaming URL rather than download the file to play it. Am I stumped before I even get started?

Hang on a minute. Syncplicity allows me to share files securely with anyone via a secure download link. Could I somehow stream from that download link?

Accessing Syncplicity content files: A quick experiment

Using Syncplicity, I chose an audio MP3 file and created a secure shared link for it. Typically, I would send this link in an email or instant message, to the recipient. Instead, I used the link directly in my Alexa Skill to see if it could be played on my Echo device.

Failure!

What was I missing here? I tried the link in my web browser and immediately saw that the link takes the recipient to a “landing page” where the file can be viewed or downloaded, depending on the file type. I had to click the “download” button to access actually the file. Hmmm. I opened the “Developer Tools” option of my web browser. This allows me to see what the web browser is doing when I access and download the file using the secure link.

Aha! I could see that the download button uses a variation of the link URL. The original secure link contains the text “/share/” within it, while the download button variation replaces that text with “/dl/” instead.  I tried this new URL in my Alexa Skill.

Success!

Suddenly, I was listening to “Satellite (Orient Express Mix)” by Moonlife on my Echo device. (Don’t worry. I asked for permission to use that song before my experiment. Nudge, nudge, wink, wink.)

Now that I had proved that Alexa could play an audio file from within Syncplicity, I updated the “My Files” skill so it would ask me if I wanted to hear the file whenever it found an audio file.

Now, when the skill found an MP3 file, it would use the “Create a shared file link” API to create a link to that file. Then, it would replace the URL text “/share/” with “/dl/” and use this URL to stream the audio.

I placed some MP3 files into my “Alexa Skills” folder within Syncplicity and tested it.

Music to my ears!

My conversation with Alexa goes like this:

  • “Alexa, ask My Files to list my syncpoints.”
    • Desktop. Would you like me to list the files and folders in here?”
  • “No.”
    • Documents. Would you like me to list the files and folders in here?”
  • “Yes, please.”
    • “Files or folders?”
  • “Folders.”
    • Alexa Skills. Would you like me to list the files and folders in here?”
  • “Yes, please.”
    • “Files or folders?”
  • “Files.”
    • Moonlife—Satellite (Orient Express Mix).mp3. Would you like me to play this?”
  • “Yes, please.”
    • <Alexa starts playing the song…>

Hurrah! A quick victory dance then I have a further thought about audio files.

Voice memos to my ears?

The Syncplicity mobile app allows me to create files right on my smartphone or tablet. I can create Word, Excel and PowerPoint type files but the app also allows me to create recordings, such as voice memos and video too.

The audio recording is saved into Syncplicity as an M4A type file. Looking at the Amazon Developer Portal, it shows that Alexa can play most audio formats, including M4A!

I quickly update the Alexa Skill so that M4A type files will also be played from Syncplicity.

My interaction with the Syncplicity mobile app follows these steps:

  • Open the Syncplicity mobile app.
  • Navigate to “Documents” and then the “Alexa Skills” folder.
  • Select the “plus” icon and then the “Record” button.
  • Tap the red “Tap to Start Recording” button when the popup appears, allowing me to dictate anything I like. (Oh, how I waxed poetic, with the immortal words “testing, testing, one, two, three…”)
  • Click “save” then upload the recording using the default file name of “MyRecord.m4a.”

Then, my conversation with Alexa goes like this:

  • “Alexa, ask My Files to list my syncpoints.”
    • Desktop. Would you like me to list the files and folders in here?”
  • “No.”
    • Documents. Would you like me to list the files and folders in here?”
  • “Yes, please.”
    • “Files or folders?”
  • “Folders.”
    • Alexa Skills. Would you like me to list the files and folders in here?”
  • “Yes, please.”
    • “Files or folders?”
  • “Files.”
    • MyRecord.m4a. Would you like me to play this?”
  • “Yes, please.”
    • <Alexa starts playing the voice memo…>

I’m used to hearing my own voice on Alexa, as my family and I are fond users of Alexa’s “announce” feature, but this is brilliant!

I can now use the Syncplicity mobile app, anywhere at any time, to record voice memos, and then play them back, via Alexa, when I get home or back to the office.

Taking it further, other Syncplicity users can share folders with me, leave their own voice memos in those folders, and I can still play those memos via Alexa.

Imagine the business applications of this, where Alexa can now be used to play any audio, whether healthcare, financial, legal, or any other information type, that you need to have delivered, and played, to a recipient!

Text to my ears?

Now that I had audio type files working, I turned my attention to non-audio files.

Again, starting as simply as possible, I chose plain text files as my next target.

The Amazon Developer Portal had already provided me with examples for coding an Alexa Skill to speak any phrase I’d like. Now I just needed to figure out how to use the Syncplicity APIs to get those phrases from text files, held within my Syncplicity account.

Text files can’t really be streamed. Looking at the Syncplicity API for the “Download file,” I found that the contents or body of the file gets returned by the API. Typically, this content or body should be saved to the system that called the API. However, for my intentions, the content or body of a plain text file would contain the phrases that I wanted Alexa to read back to me. I just had to get that content to Alexa!

I updated the “My Files” skill to look for plain text files (*.txt), prompt me, then use the Syncplicity “Download file” API to access the file contents and, finally, pass those contents to Alexa to read out loud.

Again, text to my ears!

I uploaded a plain text file, containing a soliloquy from Blade Runner (RoyBatty.txt), into my Syncplicity “Alexa Skills” folder.

My conversation with Alexa goes like this:

  • “Alexa, ask My Files to list my syncpoints.”
    • Desktop. Would you like me to list the files and folders in here?”
  • “No.”
    • Documents. Would you like me to list the files and folders in here?”
  • “Yes, please.”
    • “Files or folders?”
  • “Folders.”
    • Alexa Skills. Would you like me to list the files and folders in here?”
  • “Yes, please.”
    • “Files or folders?”
  • “Files.”
    • RoyBatty.txt. Would you like me to read this?”
  • “Yes, please.”
    • <Alexa starts reading the file, telling me how she’s seen things I wouldn’t believe, attack ships on fire off the shoulder of Orion…>

Wow! I can now have Alexa read any text file to me, just by asking her!

Yes, I admit that I had a juvenile moment when testing this, culminating with having a deadpan Alexa read back to me such literary classics as PrincessBride_BattleOfWits.txt, MontyPython_CheeseShopScript.txt and DeadParrotSketch.txt, but, the point is, I can now deliver text files via Syncplicity and have my digital assistant read the contents of those files to me.

Of course, of course, I’ll only use healthcare, financial services, legal and other business documents in demonstrations. But I’ll always have fond memories of how Alexa tried to impersonate the Sicilian reasoning of the self-proclaimed genius Vizzini and the timeless madcap exclamations of John Cleese.

What about the other files?

Now that I had Alexa playing my playable files and reading my readable files, how was I going to extend this to non-playable and non-readable files?

I thought back to the manual actions that I was trying to automate through Alexa and it suddenly occurred to me that I’d already answered this question without realizing it!

Every day, I use Syncplicity to send files securely to other recipients. Syncplicity supports sending any file size and any file type. I had already used the “Create a shared file link” API to create a link that Alexa could play from. So why not just have her send that link to me somehow?

The Syncplicity “Create a shared file link” API has an option to send automatically an e-mail containing the download link. Using this feature, I could have Alexa send me any file that she couldn’t play or read! Now I had a way to deal with any other file type.

My conversation with Alexa now goes like this:

  • “Alexa, ask My Files to list my syncpoints.”
    • Desktop. Would you like me to list the files and folders in here?”
  • “No.”
    • Documents. Would you like me to list the files and folders in here?”
  • “Yes, please.”
    • “Files or folders?”
  • “Files.”
    • HugelmportantPresentation.pptx. Would you like me to send this to you?”
  • “Yes, please.”
    • <Bing! A new email arrives, providing me with a download link to HugeImportantPresentation.pptx>

Looking back

Looking back, this experiment was far less daunting than I had expected. It helped that I was already a Syncplicity user because that meant that I already knew how to share, send and download files in a manual fashion.

I approached the APIs with the mindset of automating actions that I already performed manually. Alexa already knows how to play audio files and read phrases so all I had to do was connect the dots.

Formerly, my digital assistant could only access files and content that was held within Amazon. Now, using Syncplicity, my digital assistant can access any file of my own choosing. And let’s not forget all the files that other Syncplicity users and businesses, choose to share with me!

  • “Alexa, ask My Files to take a bow…”

Read the previous post in the series, Accessing Syncplicity content with Alexa, Part 1.