Adam Fothergill on September 26, 2016
One of the coolest new features in the Mendix platform is our Connector Kit. This allows for Connector Modules to be created and published to the app store, and then reused by the Mendix community. The best part is how it behaves in the modeler – they can easily be selected as a microflow activity, just like any of the native activities!
There are already a dozen or so connectors in the App Store – you can find them under the Connector Category:
One of the more intriguing connectors already available is the Watson Connector Suite. This has several connector options (as shown in the first screenshot), so I’ll use this as the example connector to implement. I’ll work specifically with the AlchemyAPI – the specific service of AlchemyAPI analyzes a website and ranks the relevance of keywords found on the site.
When you download the Watson Connector Suite, you will have the ‘Watson Services’ module added into your application:
Now that you have this imported, you can get it working! The first thing you must do is sign up or sign in to an IBM Bluemix account, which can be done here (http://www.ibm.com/cloud-computing/bluemix/). Once logged in, you’ll see your dashboard:
From here, you will add a new service under the ‘User services or APIs’ button. Set up an AlchemyAPI connection, as this is one of the connectors available in the connector kit. Select ‘Create’ and view the resulting information:
You’ll receive a set of service credentials, which will be something like this:
Now that you have your credentials, go back to the Mendix application and configure your application. The first thing you have to do is turn off ‘emulate cloud security’ in the project configuration – without doing this, you’ll run into security errors. After this, add a data grid of ‘WatsonServiceConfig’ to the home page so you can add your credentials (this will just allow you to run a simple test – for a production app, you’ll want to add these in the proper places). You will also put a data view of ‘KeywordRequest’ so you can pass this into the connector.
The ‘Call Alchemy’ action button will call the Alchemy API connector – it is a fairly simple microflow:
The ‘GetWatsonServiceConfiguration’ microflow simply takes in an enumeration value, and since you’re calling the Alchemy API, that is the value you will pass. With that configuration, you just need to pass the API key and the KeywordRequest object to the Alchemy connector, and you’ll integrate directly with the Alchemy API! This is where the power of the connectors lie – the complex integrations and the powerful algorithms and services on the other end of them are easily accessible. The ability to quickly add the power of Watson (or any other complex service) provides a great deal of potential business value.
This is all the work that is required in the back end – so run the application and finish setting up your configuration. The first thing you have to do is create your Watson Service Configuration for Alchemy. This is where the service credentials from before will be used:
Note that you don’t need a username or password for this service – depending on the Watson service used, different credentials are needed. Now that you’ve entered your credentials, you can request the Alchemy service – you just need to enter a specific URL and hit Call Alchemy! Note that the https:// is required!
And you get your results!
You can use similar configurations for all of the services in the Watson Connector Suite – much quicker than setting up the entire service! There is a sample app available in the app store that contains more examples. Also take a look at the blog post by Andrej Koelewijn on Introducing the Mendix Connector Kit. Take a look, and have fun adding the power of Watson to your Mendix applications!
Receive Mendix platform tips, tricks, and other resources straight to your inbox every two weeks.