Welcome to the Smart Alarm Clock (SAC for short) craft ai getting started application.
- Install Python 2.7 on your computer,
- Install pip.
First, you will need to fork this GitHub repository of the app, so that you can manipulate the behaviors and actions.
To do so, go to github.com/craft-ai/SmartAlarmClock, log in with your GitHub account and click on the Fork button, in the top right corner of the page.
You can now clone your fork on your machine using your favorite GitHub client. We'll call <sac_dir>
the destination path of the local clone.
Before making any changes, let's make sure that the SAC application is running without any problem. A little bit of customization will be needed here.
Since the SAC application needs to communicate with the craft ai server, you must expose your localhost on the Internet. This is exactly what ngrok allows to do. We'll need at least ngrok v2.0.
Download ngrok and unzip the executable file (eg. ngrok.exe
on Windows) to <sac_dir>
.
Mac users can also install ngrok using homebrew, but as we need at least the 2.0 version that is not open source homebrew cask can install it using
brew cask install ngrok
.
The following information will be required to run the application:
- your GitHub username (more precisely, the namespace in which you forked the SAC GitHub project)
- the name of your fork (default: SmartAlarmClock)
- the branch of your demo.sac fork you want to use (default: master)
Since the SAC app uses some Google services you will need to give it access to the related API by following the steps below:
- go to https://console.developers.google.com
- log in with your Google account (create one if necessary)
- create a project with the name of your choice
- open the APIs & auth menu
- go to the APIs sub-menu
- in the Google Apps APIs category, enable the following:
- Calendar API
- Gmail API
- in the Google Apps APIs category, enable the following:
- go to the Credentials sub-menu
- add a new client ID:
- click on Create new Cliend ID
- choose Web application as application type
- click on Configure Consent Screen
- put SmartAlarmClock as Product Name
- click on Save
- empty the Authorized JavaScript origins field
- put http://localhost:8080/auth in the Authorized redirect URIs field
- click the Create Client ID button
- add a new client ID:
Keep the generated Client ID and Client secret handy, you will need them later.
There is no need to enable billing for Google APIs to try out the SAC app.
You will also need to have an Application ID and an Application secret for your version of the SAC application. Those are generated by craft ai:
- go to the craft ai editor
- log in with your GitHub account - you'll need to have a beta access for this step to work
- click on the add projects button and check the box on the right of the project corresponding to your fork of the project (something along the lines of /SmartAlarmClock)
- click on the "Add 1 project" button at the bottom of the list. The project will be added to your workspace and you can select it to start editing it
- in the project explorer that appears on the left of the page, click on the cog button on the right of the project name
You will end up on the settings page which will display the Application ID
and the Application secret
needed at the first run of the application.
Install the requirements by running pip install -r requirements.txt
from <sac_dir>
Launch the application by running the command python local_demo.py
from <sac_dir>
and fill in the fields with the data from the previous steps. These fields will be saved in a configuration file, you won't have to input everything the next time you run the application.
In your browser, go to http://localhost:8080. The Smart Alarm Clock should show up and ask you to log in with a Google Account.
You can edit the behaviors by logging into the craft ai editor with your GitHub account and opening your SAC project.
In the project explorer, click on one of the behavior tree (*.bt
file) to open it in the editor.
The demo is configured using the following environment variables:
CRAFT_DEMO_SAC_URL
, the public URL of the web appCRAFT_DEMO_SAC_WS_URL
, the websocket URL of the web appCRAFT_DEMO_SAC_PORT
, the port to which the web app servers listensCRAFT_DEMO_SAC_USER
, the GitHub namespace hosting the GitHub project (either the GitHub username or the organization name to which the project belongs)CRAFT_DEMO_SAC_PROJECT
, the GitHub project containing the associated BT filesCRAFT_DEMO_SAC_VERSION
, the version branch of the GitHub projectCRAFT_DEMO_SAC_ACTIONS_URL
, the URL of the web appCRAFT_DEMO_SAC_DEPLOYMENT_DIR
, the path, in the runtime container, of the compiled BTsCRAFT_DEMO_SAC_GOOGLE_CLIENT_ID
, The SAC application IDCRAFT_DEMO_SAC_GOOGLE_CLIENT_SECRET
, The SAC application secretCRAFT_DEMO_SAC_GOOGLE_CLIENT_ID
, Google API client idCRAFT_DEMO_SAC_GOOGLE_CLIENT_SECRET
, Google API client secretCRAFT_DEMO_SAC_GOOGLE_API_KEY
, Google API key