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.

Setup:

  1. Sign-up for a Google Cloud account and setup the Natural Language API.

  2. Sign-up for a PubNub account, if you don't have one already

    1. Select Functions

    2. Select your desired App and Keyset

    3. Select "Explore Templates" and proceed with selected integration.

  3. Start the Integration Function module.

  4. Try a test message (you can click on Publish to do this).

Walkthrough:

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 google-text-analyze-v1.

  1. TEXT_LOCATION_ID: json dot notation for locating the text field in the message payload.

  2. INPUT_TEXT_TYPE: direct configuration of the Google Natural Language API property

  3. INPUT_TEXT_LANGUAGE: direct configuration of the Google Natural Language API property

  4. INPUT_TEXT_ENCODING_TYPE: direct configuration of the Google Natural Language API property

  5. OUTPUT_LOCATION_ID: json dot notation for locating the output data in the final message payload. Specify meta if you want the output data to be part of the metadata property of the message payload.

Input:

The below payload would be sent via an actual publish API call, via one of PubNub's 70+ SDKs.

1

Output:

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.

1

Talk to an expert