In this article, I am going to share how to consume or connect to a remote or external web services from Betty Blocks. We are going to create a Webservice in Betty Blocks to consume Microsoft Azure Cognitive Services for getting Tags of an image, this is via the Tag Image API (i.e. one of the Azure Cognitive Services – Computer Vision APIs).
- A valid Azure subscription – Create one for free.
- Image(s) for testing purpose and to be uploaded to an external accessible URL
- Azure Cognitive Services Resource (i.e. you may follow this link to create a new Azure Conitive Services resource
- Betty Blocks application or sandbox
- From your Betty Blocks application’s SideBar, select Tools – Webservices
2. Click the “New” button on the Webservices page to add a new Webservice, and fill in the required details.
Host and Header’s values can be grabbed from the “keys and endpoints” of your Azure Cognitive Services resource page. This is shared in the screen below.
I have specified the Request Content Type as “JSON” (i.e. this is one of the supported request content types as required by the Image Tagging API)
3. Add a new Endpoint for the Webservice
From the Webservice page, add a new Endpoint we would like to consume, screen capture below is the sample of my endpoint configuration. I have named my endpoint as “Get Tags”, and specified all other values according to the Azure Cognitive Services API documentation. (i.e. Tag Image API ).
As the Request Content Type for the Webservice was specified earlier at the Webservice level, we can leave the Request Content-type field as it is (i.e. inherit). Take note of the request payload, in our case since we specified JSON as the content-type, we will just add the body parameter of “url” as requested by the Tag Image API documentation.
4. Test the endpoint
Once configured, you may save and test the endpoint by clicking on the “Run test” button. You may be prompted to provide the input parameter or accept the default value that you have set for testing purpose.
The response will then be returned from the test as shown in the image below.
That’s all we need to do to create a simple Webservice and endpoints in Betty Blocks for comsuming web services. I hope this example helps..
The Image Tag API of Azure Cognitive Service is one of Computer Vision APIs, it gives a quick and easy way to analyze (i.e. tag) any photo or images. You may have realized the Tags returned could be at high matching rate or the other, in the event if the Image Tag API does not give us the accuracy we expected, there will be a need for us to look at the Custom Vision Service of the Azure Cognitive Services. Unlike Computer Vision Service, the Custom Vision Service allows us to specify the labels and train custom models to detect them. It allows us to build, deploy, and improve our own image identifiers for the purpose.