Google Natural Language API
Insightful Text Analysis
Derive insights from unstructured text using Google machine learning. Natural Language uses machine learning to reveal the structure and meaning of text. You can extract information about people, places, and events, and better understand social media sentiment and customer conversations. Natural Language enables you to analyze text and also integrate it with your document storage on Cloud Storage.
Sign-up for a PubNub account, if you don't have one already
Select your desired App and Keyset
Select "Explore Templates" and proceed with selected integration.
Start the Integration Function module.
Try a test message (you can click on
Publishto do this).
This Integration Function is setup to listen to a specific PubNub channel (
CHANNEL-to-text-google-analyze) but you can configure it to listen to all channels or a subset, using wildcards, e.g.
chat.*. Thus, you can add comprehension even in private chats and other secure communication channels. The Integration Block is flexible in that it can be used both as part of a PubNub messaging flow, i.e. as part of publishing data, as well as accessed separately through a REST endpoint. Additionally, customization of capabilities can be done through publish message metadata or REST query parameters. In publish metadata, the customization properties are set as part of a JSON object specific for the function named
TEXT_LOCATION_ID: json dot notation for locating the text field in the message payload.
INPUT_TEXT_TYPE: direct configuration of the Google Natural Language API property
INPUT_TEXT_LANGUAGE: direct configuration of the Google Natural Language API property
INPUT_TEXT_ENCODING_TYPE: direct configuration of the Google Natural Language API property
OUTPUT_LOCATION_ID: json dot notation for locating the output data in the final message payload. Specify
metaif you want the output data to be part of the metadata property of the message payload.
The below payload would be sent via an actual publish API call, via one of PubNub's 70+ SDKs.
In this example, the updated content is part of the published message itself. The Integration Block is setup to do an
Before Publish or Signal execution, which means that incoming message payloads will be forwarded to the Google Cloud Natural Language API, analyzed and then updated.