Objectives

Create a simple running application using Vantiq’s Generative AI capabilities.

Tutorial Overview

This tutorial demonstrates the Design Modeler, a visual IDE tool for building Vantiq systems. It uses the Design Modeler’s AI Design Assistant, a UI that allows the user to enter a text description of the system to be built then uses Generative AI to turn that description into the beginnings of the running application. The basic steps to create this application are:

  • Create a new Project
  • Use the Design Modeler’s AI Design Assistant to turn a simple application description into a Flow View and then generate a starting Design Model
  • Create a Source to receive simulated sensor data
  • Finish configuring the Design Model
  • Run the application in simulation

Note: if needed, you can import a finished version of this project using the Projects button and select Import. Select Tutorials for Import Type, then select Quickstart from the second drop-down, then click Import.

Namespace Privileges


In addition, when following the Tutorials, please make sure you are logged in as the administrator of the Vantiq namespace to which you are assigned. You can check your privilege level by clicking on your username in the title bar. If the bottom of the popup says, “Developer” or “Namespace Admin” at the bottom, you have the needed privileges. If it says, “User (Developer),” then you need to change to a Developer namespace. You may need to first create your own Developer namespace, as described here: Creating a Developer Namespace.

1: Creating a Temperature Alert Project

The first task in building the temperature alerting system is to create a Project in the Vantiq IDE.

Note: You will be alerted if you do not have permission to create a project in the current namespace. You need to change to, or create, a namespace where you have Developer or Namespace Admin privilege (see above).

Use the Project menu to select New Project, which displays the New Project Wizard. Either create a new Namespace (recommended) or add a new project to the current Namespace, select Design Model as the Project type and click Continue.

133_IntroTut_CreateProjScreen

Set the Project name to TemperatureAlert and click Go to New Design Model Dialog.

Define the Design Model as:

  • Model Name: TemperatureAlert
  • Package: com.vantiq.quickstart
  • Use AI Design Assistant

NewDesignModel

Click OK to confirm.

2: Using the AI Design Assistant

After the Design Model generation is complete, the com.vantiq.quickstart.TemperatureAlert Design Model pane is displayed:

DesignModelInitial

On the right of the pane, the AI Design Assistant is displayed. Use the text entry field at the bottom of the Assistant to enter the following text:

Receive temperature events from MQTT source 'TempMQTT'.
If the temperature crosses a threshold of 200 degrees,
notify user 'maintenance' via the 'Maintenance' Client.

This short text describes a simple temperature sensing application, reading from an MQTT Source and notifying a user when a high temperature threshold is crossed. Once the text has been entered, the Assistant displays the Generate App Flow From Description button. Click that button to send the description to the AI system to have the Design Modeler produce an App Flow, which is a graph representation of how data events will be processed by the Vantiq system. Please note the AI system response may take several seconds up to a minute or more depending on the complexity of the description entered.

The App Flow for this example will look similar to this:

AppFlow

This App Flow looks like a good representation of the example application. However, it is likely that other initial App Flows won’t match what the user imagined. The use of the Assistant is meant to be an iterative process: the description of the text is modified and new App Flows are generated until the user is satisfied with the results. When that happens, click the Edit App Flow button in the Assistant.

3: Editing the App Flow

The AI Design Assistant can only produce a high level skeleton that expresses the natural language description of your application. Next you will need to add details to turn it into a running application.

The App Flow can be further refined in the resulting Flow Preview mode:

FlowPreview

This Flow Preview contains four nodes in its graph. These represent either Vantiq Event Handler tasks or Vantiq Clients.

  1. TempMQTT: this is an Event Stream task that represents receiving the MQTT temperature sensor readings.
  2. ThresholdNode: this is a Threshold task that tests for the specified temperature threshold value.
  3. NotifyNode: this is a Notify task which sends a Vantiq Client notification message to the Vantiq mobile app.
  4. Maintenance: this represents the Vantiq Client that receives the temperature notification.

Flow Preview mode allows for adding new Event Streams, Event Handler tasks, and Clients by dragging and dropping from the palette on the left to the graph canvas. For most purposes, adding new elements to the graph will be unnecessary.

4: Generating the Design Model

Once satisfied with the Flow Preview graph, click the Generate Design Model button to create a Design Model. (If you’d like to start over to generate new App Flows using the AI Design Assistant, click the Cancel button to return to Step 2 above.)

After the Design Model is generated, the Design Model pane will look similar to this:

Design Model

The graph contains three nodes:

  1. TempMQTT: the white-titled node represents an External System. In this case, it’s a placeholder for the MQTT server that’s delivering the temperature sensor readings.
  2. TempMQTT: the green-titled node represents the Service that implements the sensor reading Event Handler.
  3. Maintenance: the purple-titled node that represents the Client that receives the temperature threshold notification.

For more detailed information about the Design Modeler, please consult its Reference Guide.

5: Create the TempMQTT Source

The application description sent to the AI Design Assistant specified an MQTT sensor data Source called TempMQTT. This Vantiq Source must be created in order to run the TempMQTT Event Stream task described in the preceding sections. This Source will receive simulated temperature readings from a public Vantiq MQTT server.

Use the Add menu to select Source…:

AddSource

Use the New Source button to display the New Source pane. Enter the following values to configure the source:

  1. Source Name: TempMQTT
  2. Package: com.vantiq.quickstart
  3. Source Type: MQTT

Add a Server URI from the Server URI tab: tcp://public.vantiq.com:1883

Add a Topic from the Topic tab: com.vantiq.mqtt.enginetemp

Save the Source.

6: Address the Design Model To Do List

The lower left of the Design Model contains the To Do List. The To Do List contains errors found in the TempMQTT Service created for the Design Modeler. These errors are normal and are associated with Event Handler tasks that need to be configured in order to have a completely running application.

Clicking on a To Do List item causes the Service pane that contains the error to be displayed. Click on the first error in the list which will cause the com.vantiq.quickstart.TempMQTT Service to display and automatically navigate to the Implement tab which contains the TempMQTT Inbound Event Handler associated with the error. The Service pane should look like this:

TempMQTT Errors

Click the TempMQTT task (the red border around this node indicates there is an error), then click the Click to Edit link in the ‘EventStream’ Activity slide out on the right side of the pane. Edit the following value to configure the task:

  1. inboundResource: com.vantiq.quickstart.TempMQTT

This task will now receive events from the com.vantiq.quickstart.TempMQTT Source from the previous step. Click OK to save the configuration.

Click the ThresholdNode task, then click the Click to Edit link in the ‘Threshold’ Activity slide out on the right side of the pane. Edit the following values to configure the task:

  1. condition: event.temperature > 200
  2. direction: true
  3. initializeCondition: false
  4. overConsecutiveReadings: 2

These values cause the ThresholdNode task to forward temperature events to the next task (NotifyNode) if there are two consecutive temperature readings above 200. Click OK to save the configuration.

Next, click the NotifyNode task then click the Click to Edit link in the slideout. Edit the following values to configure the task:

  1. title: “Temperature Threshold Crossed”
  2. body: “Temperature has crossed the threshold of 200 degrees: ” + event.temperature
  3. users: users Type: Expression, users: [Context.username()]
  4. clientName: com.vantiq.quickstart.Maintenance

These values cause the NotifyNode task to send a notification the current Vantiq user (it uses the valid Vantiq user ID for your Vantiq organization in order to receive notification using the Vantiq mobile apps) which will run the Maintenance Client whenever the temperature exceeds 200. Please note that you’ll have to add ” (double-quote) characters in the title and body property values in order to have them correctly interpreted. Click OK to save the configuration.

7: Running the Application

Save the com.vantiq.quickstart.TempMQTT Service. By configuring the two tasks with errors, the Design Modeler To Do List should be empty and the application should start running. If it is running correctly, the TempMQTT Event Handler graph should look similar to this:

Running Application

Note the rectangular badges with numbers that appear over the tasks. These badges increment as each task event is received. This means the Source is configured correctly and the TempMQTT Service is successfully receiving and processing those events.

8: Example AI Design Assistant Descriptions

The AI Design Assistant uses a generative AI engine to translate natural language descriptions of a desired system into skeletons of Design Models. Those descriptions are generally referred to as prompts. Writing effective prompts is referred to as prompt engineering. In order to make effective use of the AI Design Assistant, it’s helpful to have some examples of prompts that are good starting points to describe business processes. Below are a few examples of such prompts that translate to terms understood by the Vantiq system.

Patient Care Example

Patient vital sign events are received from the ‘/vitals’ Topic and are of type Vitals. If a vital sign property is above or below a threshold value, the vital signs are saved in the database using the Patient type and the patient’s doctor is notified using the PatientCare Client. The patient’s doctor receives the notification and interviews the patient using the PatientCare Client. Patient interview text events are received and the Patient type is updated with the new interview text. The interview text is also sent to a Procedure which generates suggestions for a diagnosis and treatment plan. The treatment plan is sent as a new notification to the doctor using the PatientCare Client.

Pump Monitoring Example

There is a pump with a temperature and pressure sensor. Join the two events together and notify a technician when the pressure is over 150. Track the technician’s location and send a notification to the factory manager when they are close. Send a notification to the factory manager when the technician has resolved the issue.

Image Processing Example

Source “imageSrc” produces an event when a person is passing through the building entrance. The event can be described as type “com.alertcalifornia.cameras”. Count the number of people entering and leaving the building. Then use those numbers to calculate the number of people remaining in the building. Generate an alert if there are more than 300 people in the building.