Skip to content

Latest commit

 

History

History
109 lines (78 loc) · 4.64 KB

index.md

File metadata and controls

109 lines (78 loc) · 4.64 KB

Introduction

Here is a quick guide to get familiar with craft ai.

The material for this tutorial is a web application that will browse reddit posts and match the titles to the names of state capitals from all over the world. When there is a match, the application will connect to the OpenWeatherMap API, retrieve the current weather for the corresponding capital and display it on a map.

Getting ready

Requirements

  • A modern browser such as Chrome 45, Firefox 39 or Safari 9,
  • A GitHub account.

Forking the GitHub repository

First, you will need to fork the GitHub repository of the craft ai tutorials, so that you can manipulate the behaviors and actions.

To do so, go to github.com/craft-ai/Tutorials, log in with your GitHub account and click on the Fork button, in the top right corner of the page.

screenshot of github fork

User configuration

The following information will be required to run the web application:

  • your GitHub username (more precisely, the owner of your fork of the Tutorials project),
  • the name of your fork,
  • the branch of your fork you want to use.

App configuration

You will also need to have an Application ID and an Application secret for your modified version of the tutorials. Those are generated by craft ai:

  • go to the craft ai editor,
  • log in with your GitHub account,
  • click on the add projects button and check the box on the right of the project corresponding to your fork of the Tutorials project (something along the lines of <github_username>/Tutorials),
  • 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 using the 'pencil' button,
  • in the project explorer that appears on the left of the page, select the craft_project.json with the cog icon.

screenshot of the project settings

You will end up on the settings page which will display the Application ID and the Application secret needed to run the tutorials.

Running

First launch

Open your browser and go to www.craft.ai/tutorials and click the Run button. You will be prompted to fill in a form with the data from the previous steps.

In the Behaviors folder field, put "bts/0". This means that the app will create its agents based on the behavior trees that are present in the folder "bts/0" of the project.

Once submitted, the data will appear in the URL like this:

http://www.craft.ai/tutorials
  ?owner=<github_username>
  &project=Tutorials
  &branch=<github_project_branch>
  &folder=bts/0
  &appid=<craft_ai_app_id>
  &appsecret=<craft_ai_app_secret>

This way you can save the url and when hitting the "Run" button from there, the form will be completed with your data and all you will need to do is hit "Submit".

Playing around

You can play around with the app and see what happens. The controls are the following:

  • Run will start an instance and display the posts retrieved from reddit in the web page;
  • Stop will stop the currently running instance which will prevent retrieving and displaying any more content, and restore the page to its initial state;

Under the hood

Here's how the application works:

  1. A craft ai agent that we will call the reddit manager retrieves the front page of a given subreddit via the GetFrontPage action;
  2. If the reddit API returns results, the reddit manager will
  • display a summary of the posts returned as thumbnails in the web page,
  • and send the results to the city manager agent using craft ai messaging system;
  1. The city manager agent will then
  • compare the results' titles with a list of capitals (GetCapitals action),
  • and for each capital matched
    • display the thumbnail in a dedicated column (DisplayCityThumbnail action),
    • and retrieve the weather and display it on a map (DisplayCityWeather action);
  1. When all of the results have been run through, the city manager agent will notify the reddit manager agent;
  2. The reddit manager agent will send a request for other posts in the subreddit, and the scenario plays again, until no more posts are found.

Next step

In tutorial 1, you will get to create your own behavior tree!