Community

Introducing the IBM Bluemix OpenWhisk Editor

Republished from the OpenWhisk blog


New to OpenWhisk?

Watch Discover dark data behind videos for an example of using OpenWhisk to build a scalable application using YouTube and IBM Watson analytics together.

We have been hard at work on a cool new addition to the OpenWhisk platform, the OpenWhisk Web Editor.

If you’re just tuning in, OpenWhisk is a serverless platform for hosting your applications. Using OpenWhisk, you can host your mobile, IoT, and web backends without worrying about deploying and maintaining servers. You can also use OpenWhisk to automate server-side processing of events. See the official announcement for more details about the core of OpenWhisk.

In this post, we introduce the OpenWhisk Editor:

OpenWhisk Editor

Our new editor allows you to quickly get up to speed with the OpenWhisk programming model. Along with the editor we are also releasing the OpenWhisk Catalog Viewer. Check it out; it’s a great place to learn about the emerging OpenWhisk ecosystem of re-usable actions and triggers.

Watch the OpenWhisk Editor in Action


Quick Overview of the OpenWhisk Editor

Until now the Command Line Interface (CLI) has been the only tool for crafting your OpenWhisk application. The OpenWhisk Editor provides an alternative to the daunting flexibility of CLI by helping you accomplish three common tasks: writing new actions, composing your code with third-party offerings into larger applications, and automating the invocation of your code.

Task 1: Write and Debug New Code

Sometimes you need to bridge existing components together in a novel way. For example, you may need to align JSON schemas or implement custom logic for filtering or grouping. Perhaps you would like to use an analytical component that adds value to your application. In OpenWhisk, you create such bridging or analytic components by authoring a new Action:

An action that logs a message

To create a new action in the OpenWhisk Editor, you first click New Action. Next, write the code, keeping in mind that OpenWhisk actions take JSON as input, and return a JSON object as their output; and they can also call console.log to aid in debugging. After writing the new action, you can invoke it by clicking Run This Action. You will then see the output of your action presented in the Console section:

Console

In OpenWhisk, since every action or feed you create automatically becomes a REST endpoint, you can call the REST endpoint directly via cURL. To see an example cURL invocation, click REST Endpoint:

REST endpoint

Task 2: Compose Your Code with Third Party Code

With OpenWhisk you can compose sequences by assembling a set of actions as inputs and outputs of each other. The result is a chain of actions that execute in the order you arrange them. You can start composing your sequence either from the blank composition interface or by selecting an existing action from the public catalog. For example, you may want a composition that uses IBM’s Watson analytics or The Weather Company’s weather forecast service. If this were your starting point, you would click on the one in Public Actions that interests you, displaying it in the Catalog Details view. Click Start a New Sequence to open the Sequence Editor already populated with your chosen public action—in this case, the weather forecast action:

Start a New Sequence
After clicking “Start a New Sequence”

After Dragging Action
After dragging your action

For more information, see Introducing the OpenWhisk Catalog Viewer. And in a future post, we will go through the process of binding and configuring third-party actions.

Continuing with the assembly of our sequence, drag any other action onto the canvas. You will see that you can form sequences of arbitrary length. Like UNIX pipes, OpenWhisk action sequences automatically feed each output as input to the next action. For example, you can personalize a weather forecast by having the next action in the sequence take the output of the general weather forecast action and filter it to present only tomorrow’s high temperature.

Finally, to invoke the sequence you composed, simply click Run This Sequence.

Task 3: Automate Your Compositions

We have learned how to manually invoke an action and sequence.

You can also schedule OpenWhisk to invoke your creations by using a public feed. For example, start a new sequence by selecting the alarm feed from the Public Feeds section of the catalog. Let’s say you want the sequence to kick off every minute:

Periodic Weather
Periodic Weather Forecast

The alarms feed will execute whatever actions you connect to it in the sequence, turning the feed into a trigger for your actions. Using cron notation, configure the feed to kick off the sequence at whatever internal you want.

Share this post:

Share on LinkedIn

Add Comment
One Comment

Leave a Reply

Your email address will not be published.Required fields are marked *


Jörg

strange tool. nothing happens when i click “Run”. My function does not appear on the left side… either this is a bug or the tutorial is missing some important things…

Reply
More Community Stories

With IBM Wearables SDK, you do the exercise, Bluemix will do the counting

To show how powerful Bluemix could be for making wearable devices really helpful, we’ve built a simple app that counts the number of repetitions you perform when you exercise. And yes, you can obtain this app and the tools needed to build your own flavor.

Best practices for developing and organizing multi-stage app deployments in Bluemix

Developing applications goes beyond plain coding – with increased and shorter development cycles there is a bigger need to deliver code in a repeatable and consistent manner – and those tasks fall under the responsibilities of the development team. We are a team in IBM developing a new Software-as-a-Service application in the IT Service Management space with a high focus on test automation and continuous delivery. Besides IBM Bluemix, there are some clever tools, that – setup in the right way – allow us to live up to our own expectations around quality and speed. Using those tools and IBM Bluemix, we learned a lot on what works well and what doesn’t, and we will share those learnings in this article with you.

IBM DevOps Services Wins Top Innovator Award

IBM DevOps Services has won the top innovator award in the coding environment category at next week's DeveloperWeek conference.