Last active
September 17, 2018 23:35
-
-
Save jcleblanc/3849a689d6e95262bc85c590ffe3a97b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Steps to creating a machine learning system | |
1. Create your JWT application with Box | |
2. Set up a webhook on a folder | |
3. Set up a lambda to listen for the webhook notifications | |
4. Upload a file using the Box file API (this will trigger your webhook) | |
5. Read in the file from Box and upload the file to your preferred machine learning system | |
6. When the machine learning system sends a notification (after processing the file) upload the new data (via the Box metadata API) to the file. | |
Resources | |
Setting up a JWT / OAuth application for working with Box APIs | |
Link: https://developer.box.com/docs/setting-up-a-jwt-app | |
Description: Takes you through the process of setting up a new app and authenticating it in your enterprise | |
Setting up the Box SDK | |
Link: https://developer.box.com/docs/install-the-sdk | |
Description: Shows you the steps for setting up one of the Box server-side SDKs | |
Auth with the Box SDKs to get a valid client (to make API calls) | |
Link: https://developer.box.com/docs/authenticate-with-jwt | |
Description: Walks you through the code needed for going through the Box auth process to begin making API calls | |
Creating a webhook on a folder to listen for file uploads | |
Link: https://developer.box.com/docs/work-with-webhooks#section-create-a-webhook | |
Description: Shows the process of creating a new webhook on a file. For the sake of the hack, we will need to create a webhook on a folder instead, and the event we will be listening for is FILE.UPLOADED. This gist is a Node example of performing those exact actions. | |
Inserting / updating metadata on a file | |
Link: https://github.com/jcleblanc/box-workshops/blob/master/section-samples-node/section-5-error-conditions/409-metadata-conflict.js | |
Description: This code sample show the process of adding or updating metadata on a file in Box. I also have a Java sample application (line 223) that shows the same process in Java. | |
AWS Lambda basic setup guide | |
Create your first lambda | |
Go to https://aws.amazon.com/lambda/ and click "Get Started with AWS Lambda" (log in if needed) | |
Click on "Create Function" in the top right. | |
Choose "Author from Scratch" at the top, add any name for your lambda under "Name", choose your "Runtime" (e.g. Node.js 6.10), leave "Role" as "Choose an Existing Role", and select "lambda_basic_execution" under "Existing Role". Click "Create Function" at the bottom. | |
From the Designer section that loads up, click on the "API Gateway" option within the left list to add it to the project. This will add the ability to have your lambda act as a listener for events that will be sent from Box and the ML / AI systems once processing is complete. | |
A new "Configure triggers" section will load on the page once the API Gateway option is added. Under the "API" dropdown in that section, click on "Create a New API". | |
Under the new "Security" dropdown, click "Open", then click the "Add" button in the bottom right. | |
Click the "Save" button at the top right of the page to save your new lambda. | |
At the top of the page, click on the name of your lambda above the "API Gateway" and "Cloudwatch Logs" options. This section will allow you to set the configuration of your app and enter in your lambda code. The "Environment Variables" section will allow you to add in key / value pairs that should be made available in your lambda. | |
Within the "Basic Settings" section, set the timeout from 0-3 seconds to 0-30 seconds, then save the lambda again. | |
Get your notification endpoint | |
Once saved, if you click on the "API Gateway" option at the top (below your lambda name), then expand the "API" section under "API Gateway" at the bottom, you will be provided with your "API Endpoint". This is the URI that needs to be provided to a Box webhook or ML / AI system for them to make requests to, which will in turn execute your lambda. | |
Setting and getting environment variables | |
To set and use environment variables (e.g. API keys for ML / AI systems), click on your lambda name at the top of the page, then scroll down to the "Environment variables" section. You can add in items such as the following: | |
key: BOX_CLIENT_ID value: 4gu255nk9mrmhgpr3c6pv | |
In your function code you can now get that BOX_CLIENT_ID value by referring to it as process.env.BOX_CLIENT_ID (Node). | |
Code sample | |
Link: https://github.com/jcleblanc/box-examples/tree/master/skills/aws-voicebase | |
Description: Connects to the VoiceBase API to do dual channel audio analysis |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment