Accessing Syncplicity content with Alexa, Part 1

accessing Syncplicity content files with Alexa
accessing Syncplicity content files with Alexa

After my success with creating an Alexa skill to call Syncplicity’s administration APIs, I decided to revisit my original goal of accessing Syncplicity content files with Alexa.

A colleague told me it would be impractical to access files with Alexa. She might read out some file and folder names but what good was that?

Accessing Syncplicity content files with Alexa

Well, I thought, my echo devices can play music and these days aren’t songs just an audio file? Why can’t I have Alexa play my files to me? If I could figure out a way to “play” things, such as text and office files, then maybe some cool things could come out of this?

All right, nice thoughts, but I have to start somewhere simple…

Starting by not reinventing the wheel

I had already got Alexa to read back lists of users, groups and policies with the “My Administrator” skill, so reading back lists of files and folders should be pretty much identical.  Instead of calling the administration APIs, I’d just call the content APIs.

Within Syncplicity, top-level folders are referred to as “syncpoints.” These syncpoints can be set to synchronize automatically with equivalent folders on your desktop PC. For example, I can add my “Documents,” “Desktop,” “Pictures,” “Music” and “Work Stuff” folders to Syncplicity and they will all become syncpoints within my Syncplicity account.

It’s within these syncpoints that all my files and sub-folders exist so it makes sense that my first step should be to see if I can get Alexa to read back to me the list of syncpoints that exist in my account.

The API for this is called “GET Syncpoints” and will return a JSON array of all your syncpoints.  How convenient is that?

I felt that I needed a new skill for this, as asking “My Administrator” to perform this task didn’t feel right, so I created a skill named “My Files.” This way, I could invoke it with phrases such as “Alexa, open My Files” and “Alexa, ask My Files to list my syncpoints.

Once again, I had to think in terms of phonetic language so that the latter invocation phrase had to be coded as “Alexa, ask My Files to list my sink points.” Ah, the joy of language. “Sink points” it is!

READ MORE: Managing Syncplicity with Alexa, Part 2.

Sinking my teeth into syncpoints

I inserted the API Call and created a simple loop to merge each syncpoint name into a list. As the list of syncpoints could be long, I also had to implement the “Alexa, stop” invocation so I could interrupt Alexa.

I sat back and tested. “Alexa, ask My Files to list my syncpoints.

Alexa verbally responded with “OK. You have the following syncpoints: Desktop, Documents, Music, Pictures and Work Stuff.” In addition, the Alexa App on my smartphone showed a text card containing this output. Very handy if you need to copy and paste any of that response.

A very nice start!

Just to make sure that this was working in real time, I added another syncpoint to my Syncplicity account, then invoked Alexa again.

This time Alexa responded with “OK. You have the following syncpoints: Desktop, Documents, Music, Oh This Is An Absurd Name For A Test Folder 123, Pictures and Work Stuff.

Success! Not to mention some minor giggling when thinking about how Alexa would pronounce the names of absurdly named syncpoints.

Files and folders

There are different APIs for files and folders. Both of them need the ID of the syncpoint as input. Luckily, the ID is returned in the earlier “GET Syncpoints” API Call so all I needed to do was save the ID along with the syncpoint Name.

As folders can be recursive, I started with files instead.

I changed the “Alexa, ask My Files to list my syncpoints” routine so that, instead of listing the names, it would prompt me and ask if I’d like to hear the list of files in that syncpoint. If I answered “yes” then it should list the files and if I answered “no” then it should move on to the next syncpoint and prompt me again.

Uh, oh. The API for files is “GET Files In A Folder.” It turns out that this API requires both the syncpoint ID and a folder ID!  A quick read of the documentation explains that each syncpoint also contains a “root folder.” In order to make this API Call work, all I need to do is supply the ID of this “root folder.” In hindsight, I see how I can target any folder by knowing its ID which, I’m sure, will come in handy later.

Once again, I changed the “Alexa, ask My Files to list my syncpoints” routine so it also captured the syncpoint ID and root folder ID for each syncpoint. Now, I should be able to list the files in any syncpoint.

Speaking of files…

My conversation with Alexa goes like this:

  • “Alexa, ask My Files to list my syncpoints.”
    • Desktop. Would you like me to list the files in here?”
  • “No.”
    • Documents. Would you like me to list the files in here?”
  • “Yes, please.”
    •  “You have the following files in Documents: 2019_Company_Holidays.pdfBudget.xlsx, Team Presentation.ppt, Weekly_Report.docx. Would you like me to repeat that?”
  • “No, thanks.”
    • Music. Would you like me to list the files in here?”
  • “Stop”
    • “OK, goodbye.”

Just like earlier, the results get updated in real time so Alexa always reads back the list of files in the folder right now.

Folders and sub-folders, oh my…

Now it was time for dealing with folders. The code I used for files can be re-used by replacing the API Call with the “GET Subfolders Of A Folder” API Call. Easy. Well, it would be if I just wanted to list those sub-folders. Rather, I want to traverse the folder structure and be able to navigate down into any sub-folder that I want. Once I get to the correct sub-folder, I still need to jump back to listing the files in it.

I realized that I needed to allow a choice between files and folders as I’m conversing with Alexa. Each time a folder is entered, Alexa should ask if I want to hear files or folders. If it’s files, list them as I did above. If it’s folders, behave just like we did in the syncpoints, list each sub-folder and ask if I want to go into that folder. Aha! I can re-use the code from the syncpoint conversation!

Talking through folders…

With my folder navigation code in place, 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.”
    • “You have the following files in Alexa Skills:
      MyFiles_25Nov2019.txt, output.log, SyncpointIntent.javascript.txt. Would you like me to repeat that?”
  • “No, thanks.”
    • Customer Success Team. Would you like me to list the files and folders in here?”
  • “Stop”
    • “OK, goodbye.”

Just as in my original My Administrator skill, I don’t have to worry about pronouncing any strange file or folder names. Instead, Alexa will traverse my folders and files, reading me their names, no matter how complex and prompt me for further actions.

Just the beginning

Being able to reach all my Syncplicity files is just the beginning.

I can picture a scenario where folders, containing important files, that have been shared with me can now be accessed “hands-free” using Alexa.

Each time I ask Alexa to open “My Files,” she will have access, in real time, to all my files and folders whether they are owned by me or are owned by someone else who shared those files and folders with me.

It’s nice to be able to list my files, but I’m already thinking about having Alexa somehow interact with those files. My next goal will be to not just list those files but actually read or play the contents to me!

Learn more about Syncplicity by Axway, a visionary file sharing platform.

LEAVE A REPLY

Please enter your comment!
Please enter your name here