VOGO Voice – Knowledge Base

Posting messages using PubNub

Estimated reading time: 3 min

PubNub is a global data stream network that accomplishes real-time data streaming and device signaling using a Publish/Subscribe model which lets you send and receive messages to any number of connected devices in a quarter of a second. 

This comprehensive tutorial serves the purpose of illustrating how to publish messages to a channel using a PubNub connector instance. Let’s outline the process citing the example of the transportation industry where truck drivers update their cargo load status through a suitable Alexa device wherein the user-specific inputs (messages) are published to a channel on PubNub network as real-time updated information to be accessed by the subscribers of the channel for a variety of business needs. 

Prerequisites: PubNub account, Alexa device (In the case of sending location information, choose an appropriate device such as Alexa Auto, Alexa Echo Buds or Alexa app on the phone) 

Setting up a PubNub connector instance

In order to create a PubNub connector instance

  1. Log into your VOGO Voice account to be directed to VOGO Voice Management Console (https://account.vogovoice.com)
  2. Navigate to Settings on the top right-hand corner of the Dashboard and select Integration from the list of tabs displayed.
    Settings > Integration
  3. Click on the Add Button on the top left-hand corner of the screen.

4. In the Select Account Type window, choose the PubNub icon from the list of connectors and click Create Connector button which opens up Add New PubNub Account window.

5. Populate the required fields in the Add PubNub Connector window.

Field values

The Publisher key and Subscribe key are mandatory to publish messages to a specific channel on PubNub Network. The aforementioned keys will be provided by the PubNub account holder to the Skill designer. 

The account holders can create the keyset from their admin portal through the PubNub Admin Dashboard. 

The additional parameters in the Add PubNub Connector window are optional fields that need to be populated depending on the requirements of the skill. 

To learn more about the additional parameters refer to the PubNub connector guide: https://university.vogovoice.com/kb/pubnub/

6. After filling in the required fields click the Save button to set up and integrate the connector instance with the platform.

Create a custom intent

Create an appropriate intent to be invoked for executing an interaction flow mapped to it to capture the input messages of individual truck drivers to be posted to a specific channel on the PubNub network.

Create an intent titled ‘Change load status’ with a set of suitable sample utterances mapped to it. Let’s say the sample utterances are: “My load status is {percentage} percent”, “Set my cargo load to {percentage} percent” where ‘percentage’ is the slot name. Assign the slot type to ENVIRONMENT_Number, which is a global slot with predefined values. 

To learn how to create custom intents refer the guide: https://university.vogovoice.com/kb/creating-intents/

Steps to Configure the PubNub connector

Once the PubNub connector has been created navigate to Interactions and click on the Interaction button at the bottom right-hand corner of the screen. Select the ‘Change load status’ intent to be directed into the Interaction builder platform.

  1. Drag and drop the PubNub component into the flow diagram area.
  2. Connect the Start component to PubNub, and PubNub to Response component to complete the interaction flow. 

🖍 Note: To interconnect the different components click on their respective Anchor symbols so as to chain and hold them in the interaction flow.

To know about the different components made use of on the interaction builder platform, refer the guide: https://docs.google.com/document/d/1BC1dmDobHxE5JZqcTh6tgf_WIlJ5sOxceteTQGPAoIU/edit?usp=sharing

3. Double click the PubNub component to access the Configuration window and fill in the required fields to capture the user input data to be published on to the channel.

Setting up the configuration fields

Name: The Skill designer assigns a name to identify the connector instance for it to be called to action in the interaction flow. 

Channel: Specify the name of the channel to which the message has to be published. 

Based on the given example, let’s assume that the name of the channel is truck_load (the channel into which the input data of all the truck drivers will get published). 

Message: It refers to the message payload that gets published to the channel containing serializable data which is usually formatted as a JSON object. 

As shown below, the message payload is a JSON object set to capture the cargo load status input data from the truck drivers to be published as messages on to the channel named truck_load.

{                                                                                                                                                                                                                                               
  currentload: {{inputs.percentage.value}}                                                                                                                                                                                              }
                                                                                                                                                                                                                                                         where ‘percentage’ is the slot name used in the sample utterance and ‘current load’ is an arbitrary name used to identify the input data. 

Store in History: Click the checkmark box of Store in History if the published messages have to be stored in the channel to be retrieved later. 

To learn about the additional parameters in the Configuration window visit: https://university.vogovoice.com/kb/pubnub/

After filling in the configuration details, double click on the Response component and type what you expect Alexa to speak in response to the cargo status update in the field titled Say. This could be: Thank you! Your load status has been updated to {{inputs.percentage.value}} percent

The message Payload format for Geolocation data

If the skill has to capture the location of the vehicle with latitudinal and longitudinal values along with cargo load status, the message payload will be modified as given below:

{                                                                                                                                                                                                                                                   
  currentload: {{inputs.percentage.value}},                                                                                                                                                                                 
  latitude: {{geolocation.latitude}},                                                                                                                                                                                                
  longitude: {{geolocation.longitude}}                                                                                                                                                                                                  }

To learn about PubNub Connector, click here.

Tags:
Was this article helpful?
Dislike 0
Previous: Fibonacci
Next: CARTO: Near Me