Chatbots can understand and respond to user requests automatically. Chatbot integrations can be useful in a variety of situations, such as customer service, new user registration, e-commerce, and anywhere you want a system to be able to respond to user requests.
With PubNub Functions, you can create a custom chatbot or connect to existing chatbot services, helping you to create real-time interactive conversations for your users. Select from a list of prebuilt Function Blocks or build an integration with a service of your choice. Here are a few suggestions:
- IBM Watson Assistant allows you to build a chatbot or virtual agent that can carry out conversations with end users in real time. The block includes a number of cognitive techniques, making your chatbot fully customizable to suit your needs.
- Amazon Comprehend uses natural language processing (NLP) to extract insights about the content of documents without needing any special preprocessing.
- Gupshup is an advanced bot and messaging platform. It enables you to quickly and easily build, test, deploy, and manage chatbots across all messaging channels. The PubNub Gupshup block connects your Gupshup bot to realtime data streams, to trigger actions based on an input.
Some Blocks require third-party service signup
When Blocks integrate with third-party services, such as Amazon, Librato, MapBox, or RingCentral, the services often require account setup to use them. Please make sure to visit each Block's documentation page, located in the Blocks Catalog, to learn what is required.
Gupshup Chatbot tutorial
Getting started with the Gupshup bot API
First, you’ll need to get started with a Gupshup account to take advantage of the Bot API.
Go to the Gupshup signup form and sign up for a free trial using your GitHub or Facebook account.
Follow the wizards to create a new bot integration using the IDE, ensuring that there is an
HttpEndpointHandlerfunction to respond to HTTPS requests from the Function.
Copy the bot name from the bots section of the dashboard.
Gupshup Function Code
Setting up the PubNub Function
Create a new function. Go to your PubNub Dashboard and create a new module, and then create a new Before Publish function. The function should be set up to trigger on a specific set of channels (such as
chat.*) or on all channels using wildcards (
Copy the function code from above. You'll need to update the API key for the service from your account.
Click Start module to start the function, and test it using the Test Payload field and Publish button on the left.
For a more detailed overview of writing a function, refer to these instructions on the Functions Overview page.
Connecting your code to a UI
In your HTML file's
<head>section, reference the PubNub scripts:
Define your Angular constructor to initialize a PubNub instance and subscribe to the
YOUR_SUB_KEYwith your app's publish and subscribe keys.
Set up your PubNub
publishfunction to query your Gupshup bot for the time of day:
You'll want to have a button set up in your template to call that function:
PubNubAngularto your main class's
Finally, add a DOM event listener to get your code running: