Sep 25, 2019
10 min

Notify your user via conversations

written by: Cognigy
image-31

A conversation is not always synchronous – not even between humans. Imagine ordering something to eat in a restaurant. Time passes while you consider the menu, chat with your companions and order a drink. For conversational interfaces to provide a similar experience, we sometimes need to break with the turn-taking pattern typical in conversation design. We accomplish this through notifications.

image-31

[A notification about an asynchronous event sent to the user directly.]

In our interactions with businesses – as consumers and employees – we often engage with business processes that have a similar kind of a time lag. You might file a support case and await a response; you might order a product and want to check on the delivery status; you might want to ask your employer about your PTO (paid time off) availability and initiate a request for time off. This is called Process Automation. It’s a scenario where notifications are particularly useful, and sometimes necessary, to complete an end-to-end activity through a conversational interface.

Some channels already allow for asynchronous message injection, but it’s not available in all cases and the specific usage is channel dependent. Cognigy.AI simplifies notifications by providing a streamlined API which hides complexity and works across webhook- or socket-based channels (for instance webchats and Facebook Messenger). You can decide if your notification is a message that notifies a user directly or if the message should be injected into the conversational flow designed in Cognigy.AI. The former is simply a message displayed in the chat history; the latter is an input injected into a Cognigy flow which triggers a dynamic response to the user.

What about Reminders for Amazon Alexa or Google Assistant?

Voice channels have strict timeouts due to the nature of a spoken conversation, which makes dealing with asynchronous notifications difficult. Fortunately, Amazon Alexa and Google Assistant expose special APIs to send notifications directly to the user. Cognigy.AI allows easy usage of those APIs (read a medium article for a Google Assistant explanation here) and provides Custom Modules for several channels including Amazon Alexa, which do not require coding skills.

Sending asynchronous messages

All you need to notify the user or inject a message into the flow are the following parameters:

  • URLToken (Required): This is the token in the endpoint URL you’ll find in the endpoint definition for a channel. Using a webchat, the URLToken might look like 3876xxxx9a47 and is the last part of the webchat URL https://webchat-demo.cognigy.ai/v2/3876xxxx9a47.
  • userId (Required): You can retrieve this Id from within a conversation in the Cognigy Input with Cognigy Script using .
  • sessionId (Required): You can retrieve this Id from within a conversation in the Cognigy Input with Cognigy Script using .
  • text: The text you want to send.
  • data: The data you want to send.

These parameters must be provided in the request body in JSON format (the content-type is application/json):

{
   "URLToken":"URL_TOKEN",
   "userId":"USER_ID",
   "sessionId":"SESSION_ID",
   "text":"Hello World"
}'

You also need an API Key which you find in your Cognigy User Profile. The API Key must be added to each API request either via the request header as X-API-Key (Header Auth) or via an URL parameter named api_key (Query Auth). The last technical detail to know is the URL to call. This depends on the environment Cognigy is running on (find a description here). If you are using our SaaS demonstration installation it is:

  • Inject message into the flow: https://api-demo.cognigy.com/endpoint/inject
  • Notify the user directly: https://api-demo.cognigy.com/endpoint/notify

If you want to learn how to use these APIs, try it out online through our API documentation here. There you get also the technical cURL commands. An Inject message using the accept URL parameter might look like:

For a Notification using the X-API-Key in the header it looks like:

What’s next?

Want to leverage notifications for your Workflow or Process Automation? Need more technical information? Have a look at our docs. Do you use Automation Anywhere, Kofax RPA, Microsoft Flow, ServiceNow, or any other RPA tool? Just get in touch with us, to see how to turn this into a natural, efficient, and fast conversational experience.

Explore More Topics

Ready to brush up on something new? We've got more to read on the official Cognigy blog.