This guide details how to call the Watson Natural Language Understanding (NLU) API from Workflows.
- Workflows
IBM Watson Natural Language Understanding (NLU) is a natural language AI service for advanced text analytics. The service can extract emotions (joy, anger, sadness, fear, and others) from text.
An IBM Cloud account is required to call the API. To create one, sign up for a free account.
Calling the Watson API
The flow to call the Watson API looks like this:
The flow has the following cards:
- The Object – Construct card creates the request body payload.
- text — is the text from which emotions are extracted.
- features — This object instructs the API to extract emotional data from text. The API supports additional text analytics features.
- The Text–Compose card sets the endpoint URL. The URL is listed on the service’s Manage tab:
- The API Connector – Post card makes the HTTP call after it receives the URL and body fields.
One last part is the connection to the API. A custom connector is created for the Watson API.
The Watson API uses Basic authentication. The connector setup looks like this:
Note: The apikey is the actual username for Watson APIs.
Service response when running with I love building no-code automation input:
{
"usage": {
"text_units": 1,
"text_characters": 36,
"features": 1
},
"language": "en",
"emotion": {
"document": {
"emotion": {
"sadness": 0.049281,
"joy": 0.9057,
"fear": 0.026308,
"disgust": 0.003774,
"anger": 0.016007
}
}
}
}
The joy score is 0.9, which indicates it is a happy text.
Related References
- How to Call an API When It’s Not Available From an Existing Card (Connection)
- Four Ways to Call an API in Okta Workflows
