Calling Google Cloud APIs
Sentiment Analysis API call:
var payload = {
"document": {
"type": "PLAIN_TEXT",
"language": "en",
"content": message
}
}
// call the Google Cloud Sentiment Analysis API and send the results back to the sentimentCallback Named Callback.
chatbox.buildCallExternalWebAPI("POST", "https://language.googleapis.com/v1beta2/documents:analyzeSentiment?key=<API KEY>").value(payload).eventName("sentimentCallback");
Civics API example:
var googleKey = "APIKEY";
if (googleKey == undefined) {
app.showAlertDialog("Google API Key Required to fetch representatives.");
app.activatePane("Finished");
} else {
var url = "https://www.googleapis.com/civicinfo/v2/representatives?key=" + googleKey + "&address=" + address;
chatbox.callExternalWebAPI('', 'civicCallback', 'GET', url);
}