loading x elements...

In this example you will learn:

  • How to use Elody as a chatbot.
  • How to detect user input in the chatbot.
  • How a Rule or Option can be made to react to an input or the creation of data.
  • How a Rule or Option can select arguments from existing objects.
  • How a Rule or Option can be made to run repeatedly, with different arguments.

The Scenario Plan demonstrating the Rule on this page can be found here: (Tutorial) Triggers.

Note that this Scenario Plan is slightly different from previous ones. It has one additional starting Tag: !scenario_chat_file_input_status. This Tag tells Elody to allow the user to upload files and visually highlights the button to do so. Check the Symbol's documentation for details.

Note about Symbols

All Symbols that start with an exclamation mark or a question mark have a special function for Elody. Check the explanation of Elody's objects for details.

The trigger

We have ignored the 'trigger' field of Rules and Options so far, even though it is actually very important.

All rules and options have access to every object that has been made available in the Scenario so far. That includes all loaded Symbols, Programs and Rules, as well as all created Tags, Files, Options, Events and Messages. For an overview of what each of these objects mean, go here.

The trigger is used to give finer control over when a Rule or Option executes. Additionally, it can also select any of the available objects in the Scenario and use them as variables, or pass them as arguments to Programs.

All we have seen so far is an empty trigger field. An empty trigger just means: Run immediately, but only once, and without any arguments.

Triggers are extremely versatile and can cover virtually any situation you can think of. A more thorough explanation can be found here. Documentation can be found here. More detailed examples follow later in the tutorial. The flexibility of triggers makes them probably the hardest part of Elody to understand.

Let's have a look at a simple example. Remember that you can open the Rule's page on Elody to get more details about the fields, as well as links to the documentation.

The Rule

Once the Scenario (Tutorial) Triggers starts, this Rule is not executed immediately. The Rule is loaded, because its dependencies are met, but it is not executed yet. The Rule waits for the conditions in the trigger before it executes.

What the Scenario does is pretty simple: You can upload a file through the file upload button, and the Rule will execute and offer the just uploaded file for download. You can repeat this as often as you want.

These are the highlights of the Rule:

  • The Rule has a trigger.
    • It has the field 'repeat' set to 'different_variables'. This causes the Rule to be able to run multiple times, but only if the new set of parameters is different from any previous set of parameters it has run with. Our only parameter is theUploadedFile, so this means that the Rule will execute once for each uploaded file.
    • The 'arguments' field lists all of the conditions of the trigger. Each argument actually defines a search process: When Elody tries to decide which Rules are applicable, it goes through each argument of a Rule in sequence and checks if there is an object in the Scenario that matches the search criteria. This means that later arguments can depend on earlier ones. We only have one argument in our example, and its search criteria are:
      • Go through the objects from last-created to first-created (search_type:last). This ensures that the Rule picks a different file each time. If you set this to search_type:first, the Rule will only execute the first time you upload a file, because all subsequent attempts to find arguments will result in the same set of parameters as the Rule just grabs the first uploaded File again.
      • Look for a Tag with Symbol ?user_input_uploaded_file. One of these Tags is created whenever the user uploads a file. The Tag targets the uploaded file.
      • Check that the first parameter of the Tag is a File (this will always be true), and assign it to the variable theUploadedFile.
  • The Rule creates a Message that offers the uploaded file for download, by referencing theUploadedFile.