Create a Workflow to Send an Email Triggered by the IoT Controller Mobile App

In this tutorial, you will:

  1. Create data from the IoT Controller app

  2. Build a workflow to send an email

  3. Test your workflow

  4. Trigger your workflow from the Medium One dashboard

Here’s what you need to get started:

  1. Medium One Prototyping Sandbox [Buy]

  2. Complete the Mobile App Quick Start Guide [Link]

Step 1. Create a Tag

To create a tag, you first need to send an event with the JSON key representing that tag. The key and tag will automatically be detected and created.

Add a JSON widget to your profile on the app.


Configure the widget with the following:

  • stream: raw

  • tag: send_email

  • select "string"


Set the value to your name and press "Send".


Step 2. Activate the tag.

Next, will need to activate the tag.  

From your Medium One web account, click Config ->Data Streams and click the raw stream.  

Look for the send_email tag you just created, check it to activate it, then Save at the bottom.

Step 3. Create a Workflow

Go to Workflow Studio, and click Create.


To specify the name for this workflow, enter “Send Email” in the top input box.


Note: Workflows save automatically.

Step 4. Add a Tag Trigger

Select the Tag & Triggers option on the Right menu, expand the raw stream input and drag thesend_email tag onto the canvas.  

Note: If you do not see send_email, that tag may not have been activated in Step 2 or you may need to refresh your browser to reload all available tags.


Step 5. Add a Base Python Module

On the right panel, click the Modules menu, open Foundation and drag the Base Python module onto the canvas


Step 6. Connect the Tag to the Base Python Module

Click the tag node output anchor and drag a connection to the input node anchor on the Base Python module.


Step 7. Edit the Python Code

Double click on the Base Python module to open the code editor.


Paste the following code into the code editor, making sure the indentation is preserved.

# import Email library
import Email
# Get input data from input named 'in1'
name = IONode.get_input('in1')['event_data']['value']
# build a basic html message
html = "<html><body>Hello, my name is {}</body></html>".format(name)
    email = Email.Email("", 'My workflow', '<your-email-here>', "You've got mail!")
except Exception:
      log("Unable to send Email")
—— copy above this line —–
Enter your own email in place of<your-email-here>‘ inside the ‘quotes’.  Example: ‘’.

The code above simply gets the data from the input, which will contain the data in the key send_email.  It then uses it to build a simple HTML message and send an email.

Check out our Email library documentation for more details on how this library works.

Click Check Syntax and make sure it passes.  If the syntax fails, you may have an indentation issue or no ‘quotes’ around your email.  If the syntax check passes, click Save and Activate.   

You can check that the workflow was activated by looking into the Revision menu.  Note the green box “activated”. Previous revisions of your workflow are stored here as well.


Step 8. Test your Workflow

Now we are going to test our workflow by sending a debug event.  

To test your workflow, let’s activate debug mode: go to the Debug menu and click the Debug Logging Enabled toggle.  This will allow logs to be captured while Workflows are run.  

Important Note: workflows in debug mode will consume 1 extra Workflow credit and may impact performance while running; be sure to disable debug mode when it’s no longer required.


In the debugger, you can send a test event. Those events do not get propagated through or show in the data; they are just for testing.

Under ‘Stream’ select raw and under user select any API user.

Note: workflows are run in context to a specific user.  The commands in the Python code are executed with respect to that user, for example, analytics.

Specify the test JSON event to send with your name in place of your name

{"send_email": "your name"}


Click Send to send the test event.

Since the raw stream was selected, sending an event that includes the send_email key will trigger our workflow that gets triggered by the raw:send_email key.

Note: Although debug events will trigger workflow they will not be saved in the database.

Step 9. Check the Logs

Now let’s check that everything went fine by looking at the logs.

Click the refresh button in the same debug panel, you should see a new log appear.


If there are errors, they will show in the error log below


If your workflow log is under “Last 10 logs” then you have successfully created the workflow!  Check your email to make sure you received it.  

Note: your account will allow up to 10 emails per hour to be sent.  After that, they will queue up.  If you require more, you can link your own Mailchimp account using our Mandrill library.

TIP: To help troubleshoot issues, you can use log statements in the code:

For example, note the two added lines beginning with log:

# Get input data from input named ‘in1’
name = IONode.get_input(‘in1’)[‘event_data’][‘value’]
log(name) #log name
# build a basic html message
html =<html><body>Hello, you just triggered an email.</body></html>.format(name)
log(html) #log html

The log data will appear under the log on debug panel - simply click on the log to view.

Step 10. Run the Workflow

You can go back to the mobile app to send the same event again to test the workflow.

However, for demonstration purposes, let’s see how we can send an event directly from the Dashboard using the dashboard User Input widget.

Go to Dashboard and scroll down the page to the widget selection toolbox.


Choose Single User - User Input.


This will create a new User Input widget. Select a user in the drop down.


Then click the gear icon to configure the tag to send data to our tag.

You can type in the search box to find the raw:send_email tag


The widget will show a String Input box.

Type in your name, and click Send to send the event.


Back at the top of Dashboard, click the Save icon (floppy disk) to save this view if you would like.


If you go back to your workflow with the debugger activated, you should see another new log created.

TIP: You can add additional input triggers by opening the Base Python, clicking the Inputs / Outputs dropdown and clicking Add Input.


The rest is up to your imagination!

Want to learn more about what Medium One can do?

Check out our documentation and tutorials & get started on your next IoT project!