Skip to main content

Hello world

Now, give this new service a try!

Let's start with something simple: a single "Hello world" screen! First, create the file java/agents/ and add the following function:

package agents;

import lombok.*;

import com.mindsmiths.ruleEngine.model.Agent;

import com.mindsmiths.armory.ArmoryAPI;
import com.mindsmiths.armory.Screen;
import com.mindsmiths.armory.component.*;

@ToString(callSuper = true)
public class Felix extends Agent {
public void showHelloScreen() {
new Screen("Hello")
.add(new Title("Hello world!"))

Every armory screen is built up of multiple components. In this case, we are only using the "Title component", but you can see a breakdown of the components we have available for you here.

Now that you have defined how your screen is going to look, let's add a rule in rules/felix/Felix.drl to activate that screen.

package rules.felix;

import com.mindsmiths.ruleEngine.model.Heartbeat
import com.mindsmiths.armory.event.UserConnected
import com.mindsmiths.armory.event.Submit
import com.mindsmiths.ruleEngine.util.Log
import agents.Felix

rule "Hello world"
signal: UserConnected() from entry-point "signals"
agent: Felix()

The UserConnected() event is emitted when the user connects to Armory, so the screen with text "Hello world!" will appear every time the user enters the link.


You can find out more about the Armory events in the section with Armory concepts.

But enough talk, let's see this in action! Run the code with forge run and click on the Armory URL you got when running armory setup.


Don't worry, in case you lost it, the format is: http://8000.YOUR-WEB-IDE-LINK (or you can just look for it in the .env file in the root of your project).

Cool, now that you're familiar with the basics, you are ready to start coding!

P.S. We don't need the "Hello world" rule, so feel free to remove it.