If you’ve ever wondered, “How do I retrieve a file using the API – it’s just a URL with an encrypted ID!”, this example should hold the answer. It uses a bot to download a file sent to a 1:1 room (a conversation between the bot and a single user), using a webhook. If your bot is in a group room, it will only be able to retrieve files where the bot is explicitly mentioned, like @botname.
For additional help creating a webhook, we recommend checking out our webhook blog and our simple (but complete) bot demo.
Alternatively, if you’re using an access token retrieved using Oauth, you can retrieve the messages in a room with this function.
In the Webhooks Explained page, the section titled Handling Requests from Spark describes the format of webhook messages. When a file is sent to the 1:1 room with the bot, the webhook will send JSON to your server containing a files key, under the data element, in addition to the other attributes such as personEmail:
The files attribute is a list of URLs (one URL if only one file is sent in a single message, multiple URLs if more than one file is sent at the same time) that will be used to retrieve the actual files. The URL for the file will be the request URL in your REST GET, and you’d just need to then pass the bot’s authentication token in a Bearer authorization header to retrieve the details (because who can view the file is limited to who is in the room – again though, in a group room, a bot’s permission is limited to messages in which it is also mentioned).
Information and additional examples on retrieving messages is detailed here.
The “Content-Disposition” header in the GET response is used to determine the file’s name and file type to be saved. The file data is the entire body of the GET response. There is no base 64 or other special encoding of the file data, so it can be written directly to the destination. So if we were retrieving an image from our example above, we would run the GET on:
The below code is an app that receives the data from the webhook and - if the data contains a files key - attempts to download the files directly to the source folder from where it is run (so if the app is located in your /Documents/Files folder, it will download the file to /Documents/Files).
We are experimenting with the web apps and macros, is it possible to enable WebGL on the board for apps such as google earth or to view CAD designs? The message "Hmm. While your browser seems to support WebGL, it i...
HiI have UCCx 11.6 premium versionIn UCCx script we want to load prompts from external media server in order to play it into the call flow menus.UCCx and media server, both are on the same LAN. We already have an URL were to download those prompts th...
Hi, I have tried to get all events from site using XML API using below code, string destinationUrl = "https://geewiz.my.webex.com/WBXService/XMLService"; string requestXml ="<?xml version="1.0" encoding="ISO-8859-1"?><serv:messagex...
Hi All, Finesse - Issue in Popup on some inbound call. I found a problem some the inbound call don't popup of the customer detail. Who is have found a problem with me? Or Who have troubleshot for this case? Please see attac...
Hi, I write voice application using tcl programming on my cisco 2821 (c2800nm-advipservicesk9-mz.124-24.T8)I tried to use infotag set leg_target_carrier_id to set carrier id as it is described in the documentation but it I get an error:Unrecogni...