Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel7

...

Having our agent build HTML

An important facet of our conversational agent is the visual support. While the way in which visuals are modelled in the agent may look complicated, there is nothing that goes far beyond basic HTML. We utilize a combination of Prolog, HTML and Bootstrap to generate dynamic webpages. Prolog rules are used to add a condition to a webpage (i.e. webpage X is shown when Clause Y is true). By means of these Prolog rules, we generate our HTML code. The HTML code is treated as a Prolog atom, essentially a string, that we manipulate with Prolog and generate with the rule. The HTML code is represented in Bootstrap format, which is also clearly illustrated by examples below or on Bootstrap's documentation website (Bootstrap Documentation).

Note

Prolog Advice: To manipulate strings and atoms in Prolog it is useful to look at documentation of the following built-in functions: atomic_list_concat, atom_concat, string_concat, append, and maplist here: https://www.swi-prolog.org/. The predicate applyTemplate is a defined predicate that will be explained below.

A Quick Prolog Walkthrough

Info

Tip: for the page ‘start’, the prolog code as already been completed. Use this one as an example on how to implement pages.

Using Prolog rules in the html.pl file

You add a condition that checks for a particular pattern ID to a Prolog rule in the html.pl file. Other simple conditions that you can add involve counting the number of recipes that are still available while in the recipe selection phase, etc. The general form of the page layout lay-out rules would be something like:

...

There are still many options to vary and for . For example, you can choose the parameters for the myPage predicate that fit your approach best.

...

The current term will display three given images on the screen. Of course, you need to make sure that the right image URLs can be displayed during the conversation, which you can do using Prolog facts in recipes.pl.

...

Other Add-ons You Can Try

...

Code Block
myMaplist(_,[],[]).
myMaplist(P,[A|As],[B|Bs]) :- call(P,A,B),maplist(P,As,Bs).

Or an An alternative method is to use the built-in list group item in bootstrap, define each item then add them to a list.

...

The speech interface is fitting to the context of a user in a kitchen, but not always feasible for testing. It may take additional time for the system to process speech input, you may be in a noisy environment, and there may be speech recognition failures. Hereby , a pointer to easily enable a textbox to be rendered for input.

...