Reference
Where to start
Flows are interactive flowcharts which tell Wia how to act when events are coming in from your devices. They are useful when you already have a device integrated with the Wia platform and you want things to happen in response to what your devices send.
To set up your device, please follow the earlier tutorial. In this section we will explain how to make the most out of flow, assuming your device is up and running.
To begin, head over to the Wia platform at dashboard.wia.io and log in to your account. You will find a tab for Flows in the left toolbar. Create a new Flow project and give it a name.
Useful Definitions
- Flows are interactive flowcharts which describe what should the Wia dashboard do in different situations.
- Devices are micro controllers which have been set up on the Wia dashboard to send information.
- Events are messages which come from devices. You can view the history of events in Wia Dashboard -> Devices -> Events.
- Blocks are the building cells of the flow. They can be connected together to describe how the Flow should operate.
Flow Interface
The flow builder works by selecting blocks from the left bar and connecting them in the desired sequence. When a parent block is activated by a Trigger block, it will activate all of its connected children blocks. These include Service, Logic and Action blocks. To activate your build, simply leave the builder and the Flow will become active.
Trigger Blocks
Trigger blocks are the beginning of the Flow chain. Your Flow must always contain at least one Trigger block. A Trigger block is activated by an external stimulus. Some blocks include:
Event Created - When a device sends an event to the Wia platform, this block will be activated. When creating this block you will need to define:
- The name of the event for which the block will be listening (you choose from all events which arrived in the past)
- The device from which the event is to arrive
Location Created- When a device sends over its location information, this block will be activated. When creating this block you will need to define:
- The device whose location will be sent over
Presence - When the Wia platform doesn't receive new messages from the device for a set period of time, this block will be activated. When creating this block you will need to define:
- The silence time after which the block should trigger
- The device of which activity is to be monitored
Timer - This block can be used to trigger according to time. It can be set in two modes:
- You can select it to trigger at a specific time each day - for example, every day at 11:00
- You can select it to trigger regularly - for example, every hour.
Run Flow - This block is useful if you wish to trigger the Flow manually. After placing this block you will be able to trigger the Flow from places such as your smartphone.
Service Blocks
Service blocks perform useful operations on data they receive. There are some cool features that perform useful processing in a convenient way. Some of the blocks here include:
AWS Detection - If your device sends a photograph with its event, this block can be used to assess whether the photograph contains a specified object and activate the following block upon success. The objects which can be detected include:
- Detect Faces
- Detect Labels
- Detect Text
HTTP Service - This block is designed to perform a GET / POST request based on a specified URL. You can append the request with additional headers when creating the block. This allows for an external server to perform further operations upon receiving your request.
Logic Blocks
Logic blocks provide code-like implementation to the Flow builder. They allow the Flow to work with previously saved variables and act upon them. In Flows, variables which will be saved on the platform are called States. You can manage states by going to Device > Settings > States. Here you will be able to input a key and its corresponding value.
Some of the blocks in this category include:
Check State - When this block is triggered, a comparison operation will be performed on one of the device's states. If the comparison is successful the block will trigger the following Flow. To create the block you must define the state's key and a comparison value. You can then specify one of operations:
- Equal to
- Greater than
- Less than
- Greater than or equal
- Less than or equal
Update State - When this block is triggered, the specified state's value will be overwritten.
Run Function - This node / block is used to input your own code to control the execution of the flow.
When this block is triggered, its containing Javascript code will be executed
The code it supports is ES6 Server Side JS (eg. no window or DOM object) and nodeJS variables.
To learn more about run functions - see this link here
Repeat - When this block is triggered, it will trigger the following block for the specified amount of times. This block allows for an operation to be performed multiple times on a single trigger.
List Devices - Generate a list of all devices
Action Blocks
These blocks are the end-blocks of the Flow which can perform actions upon final conclusions of the Flow. They can be triggered by other blocks, but do not create an output and therefore cannot trigger further blocks themselves. These blocks can be split into categories as:
MessageBird
- You can enable MessageBird integration with Wia and access the phone network. This includes sending SMS and Voice Messages. While Wia provides the trigger for these modules, you will need to make sure that your MessageBird account is properly configured to perform these operations on your behalf.
Wia Platform
Email - When this block is triggered, an email will be sent to the specified address. You can make use of special variables in your email body which will be inputted by the system before sending - including:
- Device ID
- Event ID
- Event Name
- Event Data
- Location ID
- Location Latitude
- Location Longitude
- Location Altitude
Event - When this block is triggered, an event will be sent to your Wia dashboard under the Device tab..
Location - When this block is triggered, a location event will be saved to your Wia dashboard under the Device tab.
Notification - When this block is triggered, an App Notification will be sent to the users with access to this device. You can limit the notification to specific users or send the notification to all users.
Run Command - When this block is triggered, the selected Javascript command will be run.
Webhook - When this block is triggered, a Webhook will be created with the specified details.
Slack
You can enable Slack integration with Wia and send messages to channels or SlackBot.
Twilio
You can enable Twilio integration with Wia and access the phone network. This includes sending SMS and Voice Messages. While Wia provides the trigger for these modules, you will need to make sure that your Twilio account is properly configured to perform these operations on your behalf.
You can enable Twitter integration with Wia and automatically tweet on your behalf.
AWS
By enabling Amazon Web Services integration with Wia you can enable the block to upload the data it receives to the S3 platform.
States
A state is a variable which is stored on the Wia platform. Each state has a key which identifies it, and a value which describes its contents. You can add new states by visiting Devices > Settings > Add State. Each state is owned by a specific device listed on your Things list.