Introducing AT&T's Flow

AT&T Flow is an intuitive visual tool that enables you, the IoT developer, to create your prototype, iterate and improve through multiple versions, then deploy your application.

AT&T Flow offers nodes that are preconfigured to allow easy access to multiple data sources, cloud services, device profiles, and communication methods. The integrations are already done for you, so you only have to focus on wiring the building blocks together to create your IoT application. This Flow Desiner getting started guide will help you get up to speed fast.

Overview
  • Devices: sends data periodically, may also receive data, commands, updates.
  • AT&T IoT Platform
    1. M2X data store: Stores the data from all devices, may initiate triggers on pre-designated thresholds
    2. Flow IDE: fully hosted, Node-RED based programming environment with ability to maintain versioning, publish and run solution on AT&T IoT PaaS. 'Do something' with the data, create an application that is ready for end users to consume
    3. IoT PaaS: Create multiple, completely separated environments (e.g. sandbox, staging, production), each containing multiple dockerized servers, manage the scale and resources for each environment, as well as the version running on it and do all that on demand, without spending capital upfront
  • End User Devices: browsers, mobile devices, etc. - consume/use the application/ services
Create your first project

Projects contain the flows that together make your application. Let's start by creating your first project:

  • On the main screen that appears after login, click on the 'New Project' button
  • Give your project a name, something like 'My first project'. You can also add a description if you like, 'Testing Flow' for example.
  • Keep 'visibility' to private (you can always change it later). 'Internal' or 'Public' visibilities allow others to see your project, clone it, etc. and is great for collaborative work. For now, we'll keep this first project Private.
    Click 'Save'
  • The system will import the required template files and will set the environment for you. Once done, your new project is in 'Edit' mode, ready for you to write your first flow.
Create your first flow

Your project was created with a default first flow called 'Sheet 1'. Rename that flow to 'My first flow' by clicking the dropdown menu on the top right of the canvas and hitting save.

Now, let's write some code. Flow uses 'nodes' as the main building blocks and wires between these nodes to create the flow of the application. We'll start with a few basic nodes.

  • Add an Inject node. The Inject node allows you to inject messages into a flow, either by clicking the button on the node, or setting a time interval between injects.
  • Drag an Inject node from the left palette onto the central workspace area.
  • Select the newly added Inject node. You will see information about its properties and a description of what it does on the right Info pane.
  • Add a Debug node and place it to the right of the Inject node. The Debug node causes any message to be displayed in the Debug sidebar. By default, it just displays the payload of the message, but it is possible to display the entire message object.
  • Wire the two together. Connect the Inject and Debug nodes together by dragging between the output port of one to the input port of the other.
Test your flow
  • Test your flow in the sandbox. At this point, the nodes only exist in the editor and must be deployed to the sandbox environment.
  • Click the Test in Sandbox button. You'll see a progress report updated you on the status of the build. Once successfully completed, your flow has been built and deployed to the AT&T IoT Platform as a Service (PaaS), to a special default environment created for each project called 'sandbox'.
  • Select the 'Debug' tab on the sidebar. System will switch into 'Connected' or 'Debug' Mode
  • Now click the small 'button' to the left of the Inject node. You should see numbers appear in the sidebar.
  • By default, the Inject node uses the number of milliseconds since January 1st, 1970 as its payload. In the next step, we will do something more useful with that.

With the Debug sidebar tab selected, click the Inject button.

Modify and retest your flow
  • Add a Function node. The Function node allows you to pass each message though a JavaScript function. Wire the Function node in between the Inject and Debug nodes. You'll need to delete the existing wire (select it and hit delete on the keyboard).

    Double-click on the Function node to bring up the edit dialog. Copy the follow code into the function field:

    // Create a Date object from the payload var date = new Date(msg.payload); // Change the payload to be a formatted Date string msg.payload = date.toString(); // Return the message so it can be sent on return msg;
  • Retest your flow. Your new flow is back in edit mode. Click the 'Test in Sandbox' to rebuild and deploy it into AT&T IoT PaaS sandbox environment. Wait for the build and deploy process to finish successfully.
Import a flow

It is sometimes useful to reuse a piece of code you or someone else wrote. There are two ways of doing that in Flow: Import and Fork a project. We will learn about forking shortly, but for now, let's focus on import.

  • The JSON annotation below represent a simple 'hello world!' flow, using only inject and debug nodes, much like your first flow. Copy it to your clipboard using the copy button below or by simply select and copy (Crtl+C for Windows, Cmd+C for Mac, etc.) [ { "id": "8a6b7414.759488", "type": "inject", "name": "", "topic": "", "payload": "Hello World!", "payloadType": "string", "repeat": "", "crontab": "", "once": false, "x": 189, "y": 113, "z": "fa46b5ad.05b948", "wires": [ ["20ed12f0.df12ee"] ] }, { "id": "20ed12f0.df12ee", "type": "debug", "name": "", "active": true, "console": false, "complete": false, "x": 445, "y": 114, "z": "fa46b5ad.05b948", "wires": [] } ]
  • In your Flow project, click the menu -> Import from... -> Clipboard... (see example screenshot below)
  • Paste the JSON annotation from your clipboard and click OK
  • The flow will appear and will allow you to place it on your canvas. Make sure you place it on a clean spot, possibly below your existing flow.
  • Click Test in Sandbox button again to build and deploy the entire flow, including this new one. System will rebuild and deploy the code to the sandbox environment.
  • Once done, test the new element by selecting the debug pane on the right and clicking on the button next to the Hello World (inject) node. You should see 'Hello World!' in the debug window.
Fork public projects

Now, let's try forking a project. Unlike import, forking takes the entire project, clone it and 'make it your own' so you can start working where the cloned project left off. Let's give it a try.

  • Assuming you are still logged in, select the Resources->Explore option. See below:
  • Search or scroll available projects to find the one you are interested in. You can also select the 'Most stared' project to see the most popular ones.
  • Clicking on a project you consider forking will show you additional details on it, assuming the creator took the time to provide them. See example below
  • For this example, choose HTML1 project, that can be found here and click the 'Fork' button next to it
  • The system will clone the project to your space. Once finished, click the Flow tab. you should see something like this:
  • You can now explore the project nodes and code, test it, make changes, etc. This specific project checks the AT&T stock price on the Yahoo Finance web site and returns the price and 'true' if it is above than $30/share
  • Try to click the Deploy in Sandbox button to test the project functionality. You can then modify it to your needs and test again.
Next Steps