Calling your new Choreos


Now that you've built your very own Choreo, we figured you'd want to know how to call that Choreo from your code. One approach you can take is to automatically generate an SDK in the language of your choice that contains your new Choreos combined with our full Library of Choreos. That's the approach we recommend if you want to work in your favorite languages. Alternatively, there are two other approaches that involve calling our platform directly to access your new Choreos. This tutorial explains them both.

From Our REST API

Every Choreo in our Library comes with an auto-generated cURL snippet that uses our REST API to call Choreos. You can use this approach to call your custom Choreo from any programming language that supports HTTP. Here's an example of a cURL request that executes a Choreo that someone has built in Twyla:

curl --basic -u APP_NAME:APP_KEY --header "x-temboo-domain: /ACCOUNT_NAME/master" --header "Content-Type: application/json" --header "Accept: application/json" -X POST --data '{"inputs": [{"name":"MyFirstInput", "value":"test 1"}, {"name":"MySecondInput", "value":"test 2"}]}' "https://ACCOUNT_NAME.temboolive.com/temboo-api/1.0/choreos/MyFolder/MyCustomChoreo"

If you'd like to learn more about working with our REST API, you should check out these tutorials.

From an Arduino or Texas Instruments LaunchPad

When browsing any Choreo in the Library, you'll see that you can generate an Arduino or Texas Instruments LaunchPad sketch that calls the Choreo. Adjusting these code snippets to work with a Choreo you've built yourself is just a matter of changing the name, URI, and inputs of the Choreo that you want to call. Here's an excerpt from a sketch that calls a custom Choreo:

    ...

    // create a TembooChoreo instance
    TembooChoreo MyCustomChoreo;

    // invoke the Temboo client
    MyCustomChoreo.begin();
    
    // set Temboo account credentials
    MyCustomChoreo.setAccountName("ACCOUNT_NAME");
    MyCustomChoreo.setAppKeyName("APP_NAME");
    MyCustomChoreo.setAppKey("APP_KEY");
    
    // set the name of the choreo we want to run; here, we've created a custom choreo called "MyCustomChoreo"
    // and saved it to a folder called "MyFolder".
    MyCustomChoreo.setChoreo("/MyFolder/MyCustomChoreo");
    
    // set choreo inputs; in this case, we have two inputs called "MyFirstInput" and "MySecondInput".
    MyCustomChoreo.addInput("MyFirstInput", "test 1");
    MyCustomChoreo.addInput("MySecondInput", "test 2");
    
    // run choreo; when results are available, print them to serial
    MyCustomChoreo.run();

    ...

Need Help?

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


Back