Auto-Generate Application Logic with Conditions

Temboo doesn't just generate the code you need to connect your hardware devices to the internet, it goes beyond that by letting you specify production-ready application logic too. You can use Conditions to specify the sensor conditions that should trigger an action on Temboo. You can also trigger events on your board based on the response your board receives from an API call. The best part is that we've written the code for you.

Cool right? In this tutorial we'll show you how to harness the power of Conditions.

To demonstrate Conditions, we're using the Twilio > SMSMessages > SendSMS Choreo, but you can use Conditions with any Choreo in the library.

1To set up your Conditions, you'll need a Temboo account. If you don't already have one, you can register for a free account here.

2We've already created a free Twilio account, which we need to obtain the credentials we need to run the Twilio Choreos.

3The Choreo needs a Twilio phone number, along with the Account SID and Auth Token. Here's what ours look like in the Twilio dashboard.

A Twilio Account SID and Auth Token in the Twilio dashboard

Set your conditions

4Back on the Choreo page, we've used the drop down menu at the top to select our development platform, the board we're using, and how it's connected to the internet.

5Before adding our inputs, we'll set the condition on our board that should trigger the text message to get sent. Start by setting up a sensor on the virtual board. If you don't have a sensor yet, you can simply read directly from the pin like we do in the gif below.

6With your sensor in place, you'll see an option to set a condition based on your sensor value. We'll select the sensor we just set up. We want the text message to get sent if the sensor value is higher than 50, so we'll click the operator dropdown menu and choose the greater than sign, and change the number 0 to 50. We can also set how many times we want our text message to send in the event that the condition is met - this helps prevent sending too many alert messages.

7Next, we'll plug in the Account SID and Auth Token as well as your Twilio phone number in the From field. Add a message in the Body field and who the phone number where the message should be sent.

8Now we'll add our Twilio "From" number. This is the number that you've purchased or received from Twilio.

9In the "To" number field, we'll add the phone number where we'd like to send an SMS. Finally, we'll add the "Body" of the message. If we scroll down to the code block, we can see that each of the inputs have been added to the auto-generated code.

10Our code is ready to run, so we could upload the code below to our board and when our sensor value goes over 50, the text message would be sent, but what if the message is being sent to someone else? How will we know that the code ran successfully? It would be useful if an LED light came on as soon as the text message was sent. Luckily with output triggers we can make that happen.

Trigger a hardware event

11First we need to set up an actuator to trigger the hardware event on, so we'll do that on pin 13.

12Each Choreo has its own set of response outputs that are returned when the API call is made. You can see a definition of each output right on every Choreo page. There's also a success message returned by every Choreo, which indicates if the API call was made successfully. We're going to use the success state to set our conditional.

13That's all there is to it. Our code has been live updated as we've edited our Conditions and it's ready to run. Now when we upload the code to the board and the sensor value goes over 50, a text message is sent. When Twilio tells our Arduino that the message has been sent, our LED indicator will glow!


Now that you've figured out how to work with Conditions you're ready to start building an application with any of the 2000+ Choreos in our Library.

Need Help?

We're always happy to help. Just email us at support@temboo.com, and we'll answer your questions.