Community

Introducing the IBM Bluemix OpenWhisk Editor

Share this post:

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.

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

Bluemix monitoring dashboard Quick Reference

In Bluemix, you can use the logging and monitoring service to monitor Containers or Virtual Machines usage metrics and debug your applications. To monitor the resource usage metrics, track health, and have a reference for problem determination, you can use the Bluemix monitoring dashboard that is based on Grafana. This blog provides a quick reference guide for the Grafana dashboard user interface. More...

Continue reading

Embracing hybrid cloud with IBM VPN service

Are you looking to gain competitive edge by going hybrid? Do you have workloads that can’t be transitioned completely to cloud? Do you want to be selective about which workloads stay in-house versus which move to cloud? Are you unclear about how your on-premises assets may be able to communicate with your cloud resources? Look no further than the IBM VPN service.

Continue reading

Caching in the Cloud

BlueMix includes a general purpose caching service powered by WebSphere eXreme Scale to really accelerate your applications in the cloud. You can use this cache to store user profiles, store frequently accessed data, or as a general purpose state store for your application. There are two primary APIs to the Cache: Java and HTTP REST. You can learn more about these APIs in the WebSphere eXtreme Scale InfoCenter.

Continue reading