Introducing the Mendix Connector Kit
Starting with Mendix 6.6, everyone can extend the Mendix Microflow functionality with native actions. These actions will be completely integrated with the Mendix Modeler, and will be just as easy to use as the actions you know in Mendix.
The goal is to have a rich set of predefined connectors in the Mendix App Store that will enable anyone to quickly build composite applications on top of existing services.
Here’s a simple example of what you can build using these connectors. The following microflow gets the status of an IoT device from Amazon AWS and stores the state received in an entity using a visual mapping. Next it checks if the device reports a temperature over 25 degrees Celsius. If so, it posts a status message to Twitter. Finally, it checks if the device reports that the lights are on. If this is the case, it will post a message to a Slack channel.
This is just a simple example. By using connectors for Amazon Machine Learning or IBM Watson you can add intelligence to your applications by predicting certain aspects based on your data. This will enable you to build Smart Apps.
You may wonder why you need connectors if Mendix 6.6 also includes native support for REST consume? Why do you need connectors when you can also use REST? Most services these days have a REST API, but using APIs is not always very straightforward, especially when using secured APIs. To solve this, most services offer a client SDK, which takes all the hard work out of calling the service. Mendix connectors hide the complexity of using a service in a similar way for the users of a connector, typically Business Engineers. Internally, the connector may use the SDK provided by the service provider, or it may use the REST API, or some other means of communication. This is up to the developer of the connector.
What is the Connector Kit?
The main building block of a connector is a Mendix Java action. The Connector Kit builds on these Mendix Java actions and improves on them in two main areas.
First, we are making Java actions more powerful by providing new parameter types. You will be able to pass parameters referring to parts of your application like entities, microflows, mappings, and pages. Other parameter types that we will introduce are string templates that can merge text and values. In Mendix 6.6 we’ve included Type parameters, or generics as some people like to call them. More on this later.
Second, we are improving ease of use. We think everyone should be able to use connectors, and using them should not be any different from using the core parts of the Modeler. End users should not see any difference between a retrieve action and a Twitter action.
In Mendix 6.6 Java actions can be included in the Microflow toolbox so they appear as a native part of the Modeler. No longer do user have to search through complex technical modules to find the correct Java action. The toolbox has also been improved with a search function that will quickly show you the relevant actions.
Going forward, we will make using connectors even easier. For example, you will be able to select microflows or entities, or any value for a parameter that refers to a part of your model, using a select window. You will not have to provide the name of the object; instead you can just select it. This name will also be automatically updated when you rename an object, so refactoring your project will be easier and cause less errors.
Connectors can be downloaded from the Mendix App Store, similar to other content for Mendix. A short list of some of the connectors that are available in the App Store or that will be available soon:
- Database connector – Import data from other databases by executing SQL statements. You can also use this connector to update and modify data in external databases using SQL.
- IBM Watson services – Use the IBM Watson machine learning services to recognize images, analyze texts, or provide users of your application with a conversational interface.
- Amazon IoT connector (Beta) – Connect with your IoT devices through Amazon IoT to read and change their status.
- Amazon Machine learning connector (Beta) – Make predictions on your data in Mendix by executing machine learning models in Amazon Machine learning.
- Push notifications connector – Send native notifications to users of your mobile Mendix applications.
- KPN Lora connector – Receive messages from IoT devices connected through the KPN Lora network. This connector is provided by our partner First consulting.
- Twitter connector – Post updates to your Twitter timeline or send direct messages to your followers on Twitter.
- Slack connector – Post messages in Slack channels and send direct messages to people on Slack.
How to Create Your Own Connectors
To create your own connector, you just create a Mendix project with a module containing everything required for the connector. When you have implemented the required functionality you can export the module and upload it to the App Store.
To make your connector easy to use, you need to make sure that all use of your connector is handled by Java actions. The Java actions are the API to your connector. When using your connector, your users will see the available actions in the toolbar when they are editing a microflow. Make sure they can find everything they need in the toolbox, so they don’t need to dive into the module itself.
To ensure a Java action is visible in the toolbox, you can specify this in the expose as microflow action section of the Java action definition. Additionally, you can specify a caption for the action, a category for the toolbox and an Icon. These will be used in the toolbox, and also in the microflows, so these will be easy to read for your user.
Another new tab in the Java action dialog is the Type parameters tab. These type parameters enable you to specify that multiple parameters of your Java action are using the same entity, as specified by the user when modeling his application. For example, you action may be calling a register vehicle service. If the user specifies a car entity as input, it should also return a car. But if the user specifies a motorbike entity as input, the action should also return a motorbike. You can use a type parameter for this.
We will be adding more new parameter types in the future, so you will be able to specify that the user of your microflow action needs to specify a microflow, an entity, or a mapping.
Mendix connectors will be open source, available on Github. You can already look at a number of these connectors today, so you can see how to build and extend them. Here are a few to start with:
- Database connector: https://github.com/mendix/database-connector
- Twitter connector: https://github.com/ako/TwitterConnector
- Slack connector: https://github.com/ako/SlackConnector
Everyone Can Build a Smart App
The Mendix Connector Kit opens a new world of composite Smart Apps. Everyone will be able to quickly and easily combine actions in a microflow to read IoT data, analyze the data, make predictions, and inform users of these predictions. Mendix, the fastest and easiest way to build smart experiences!