Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: (Classic)

Creating The Ruleset

First things first, you need to create a ruleset. You can either do that through the KRL Ruby Gem or through AppBuilder. For everything after this point, I'll be using the KRL Gem, and I suggest you do too.

Once you've installed the KRL Gem installed, run

Code Block
languagejavascript
themeConfluencelanguagejavascript
krl create 'Hello World'

to create an app. It will create a directory with a name corresponding the RID of the new app. A file with RID and a extension will be in the directory.  You can rename the directory to anything you want.  In my case, I changed mine from a41x216 to HelloWorld.

Modifying the Ruleset

Next, modify the ruleset to respond to the CloudOS events. Open your ruleset in your favorite editor. You should be greeted by a ruleset that looks like the following:

...

The first task is to remove the placeholder rule (the rule named first_rule). Then create a new rule named HelloWorld:

Code Block
languagejavascript
themeConfluencelanguagejavascript
rule HelloWorld {
 
}

The select statement defines the event conditions under which this rule will be selected. The CloudOS raises the web:cloudAppSelected event whenever a user clicks on an app to run it. So, we want our HelloWorld app to be looking for that event and respond to it. With the select statement added, your rule should look like this:

...

These are actions are defined within the SquareTag and CloudRain modules. Note that we have not yet imported these modules. Let's go import those modules now.

Importing the CloudRain and SquareTag modules

KRL modules can be defined and imported into other rulesets. A module is literally just a ruleset that provides functions and actions for you to use. See the Modules page for more info on modules. We have two modules that we are trying to use (CloudRain and SquareTag) that have not been imported yet. To import these two modules, add the following two lines into the meta block:

...

The only thing that can cause an error at this point is a syntax error. So if there are errors, use the command krl check to check the syntax. It will provide line and character numbers of any syntax errors. 

Running the App

After you've created, commited, and deployed the ruleset, the next step is to run your app!

...

If you don't see this, check the preceding steps. The information on debugging KRL rulesets might also be helpful. 

Next Steps

Once you've got your CloudOS app running, you might want to know how to make it run when someone scans it. The Creating a SquareTag application tutorial builds on this one to say hello to you every time you scan a tag.