1/98 NLP APIs

Let’s start from the pre-built APIs as one of the NLP development tools.

You’ll focus on the Dialogflow API and be introduced to the Natural Language API.

2/98 NLP APIs

Dialogflow is a natural language understanding (NLU) platform to design and integrate a conversational user interface

3/98 NLP APIs

into your mobile app, web application, device, bot, interactive voice response system, or similar use.

The Dialogflow API can be used to build a human-like agent to interact with and engage your customers.

4/98 NLP APIs

Dialogflow can analyze multiple types of input from your customers, including text or audio inputs (like from a phone or voice recording).

5/98 NLP APIs

It can also respond to your customers in a couple of ways, either through text or with synthetic speech.

6/98 NLP APIs

Dialogflow provides two types of services in terms of the complexity of the problem and the size of the data:

7/98 NLP APIs

Dialogflow ES —ES standing for Essentials— provides the standard agent type suitable for small and simple agents.

8/98 NLP APIs

A Dialogflow agent is similar to a human call-center agent;

the only difference is that it’s a virtual (or machinery) agent.

You train the Dialogflow agent to handle conversation scenarios based on a large amount of data such as past conversations or an existing knowledge database, the same way you train a human call-center agent.

9/98 NLP APIs

Dialogflow CX —CX stands for Customer experience— provides an advanced type suitable for large or complex agents.

Let’s compare these two services in more detail:

10/98 NLP APIs

In terms of the target problems that we just mentioned, Dialogflow ES focuses on small and relatively simple problems;

Dialogflow CX targets larger and more complex problems.

11/98 NLP APIs

Dialogflow ES allows one agent per project.

CX has different types of agents, such as sales agents, marketing agents, and customer service agents, and allows up to 100 agents per project.

12/98 NLP APIs

For the building blocks of a virtual agent, Dialogflow ES uses a flat structure called intent. Dialogflow CX uses a graph structure of flows and pages.

13/98 NLP APIs

When you create an agent on the Dialogflow Console, Dialogflow ES provides text forms;

Dialogflow CX gives you a visual representation that shows conversation paths.

14/98 NLP APIs

And last, the primary benefit of using Dialogflow ES is to allow a small company to create an agent quickly and affordably.

Using Dialogflow CX instead of ES allows a large enterprise to create multiple virtual agents and better scale across multiple development teams.

15/98 NLP APIs

With a brief idea of the differences between these two services, let’s focus on Dialogflow ES.

16/98 NLP APIs

Dialogflow handles conversation in almost the same way as a human interaction.

17/98 NLP APIs

Imagine a conversation: You ask Google Assistant

18/98 NLP APIs

can you send me a reminder?

Google Assistant may respond …

19/98 NLP APIs

what do you want to be reminded about?

You reply …

20/98 NLP APIs

“Mom’s birthday is on May 1”.

Google Assistant asks a follow-up question:

21/98 NLP APIs

do you want to add it to Google Calendar?

You reply …

22/98 NLP APIs

“yes, please!

23/98 NLP APIs

You might have noticed three major components involved in this conversation.

24/98 NLP APIs

First is the topic, what is this conversation about?

What does a customer want?

So what do you think the goal of this conversation?

25/98 NLP APIs

Right, a reminder.

The customer needs to set up a reminder.

26/98 NLP APIs

In Dialogflow, we call the topic or the goal of a conversation as intent, and it indicates the intention from a customer, for example,

27/98 NLP APIs

setting up a reminder,

28/98 NLP APIs

asking for the weather,

29/98 NLP APIs

or checking an account balance.

30/98 NLP APIs

Based on the data from tons of conversations, Dialogflow built a database that includes the popular intents.

31/98 NLP APIs

When an end user writes or says something, referred to as an end-user expression, Dialogflow matches the expression of an end user to the intent in the database.

Matching an intent is also known as intent matching or intent classification.

32/98 NLP APIs

Two algorithms are used to match an intent: rule-based reasoning and machine learning matching.

33/98 NLP APIs

Rule-based reasoning refers to the traditional decision tree.

For example, do you like dogs or cats? If cats, do you like long hair or short hair? If short hair, here are the three choices.

34/98 NLP APIs

ML matching uses machine learning models to teach the machine from a large number of conversations in order to identify intents and matching keywords.

Dialogflow simultaneously attempts both algorithms and chooses the best result.

35/98 NLP APIs

After identifying the intent, or the topic of a conversation, the next task is

36/98 NLP APIs

identify the entities, or the specifics of the topic.

In this conversation, what would be the specifics of the reminder?

37/98 NLP APIs

The reminder is about mom’s birthday, and the date is May the first.

38/98 NLP APIs

You can think of entities as

39/98 NLP APIs

related to the details, or the specifics, of an intent, such as

40/98 NLP APIs

who,

41/98 NLP APIs

what,

42/98 NLP APIs

when, and

43/98 NLP APIs

where.

For example,

44/98 NLP APIs

this reminder needs to be set to a certain date,

45/98 NLP APIs

and this reminder is about a birthday.

46/98 NLP APIs
47/98 NLP APIs

Dialogflow provides predefined system entities that can match many common types of data, such as dates, times, colors, and email addresses.

48/98 NLP APIs

You can also create your own custom entities for matching custom data.

For example, you could define a vegetable entity that can match the types of vegetables available for purchase with a grocery store agent.

49/98 NLP APIs

After the intent (or the topic of a conversation) and the entities (or the specifics of the topic) are identified,

50/98 NLP APIs

the third component is the flow of the conversation.

For example, in this case, Google Assistant understands the details of the request

51/98 NLP APIs

then asks a follow-up question if the end user wants to save the reminder on Google Calendar.

52/98 NLP APIs

The conversation can continue to ask the users if they want to send flowers a week before the birthday.

53/98 NLP APIs

Based on the answer, Google Assistant might continue to ask which flower shop to call

54/98 NLP APIs

or end the conversation.

55/98 NLP APIs

This conversation flow is based on

56/98 NLP APIs

context.

Dialogflow contexts are similar to natural language context.

57/98 NLP APIs

If a person says to you “they are orange”,

58/98 NLP APIs

you need context to understand what “they” refers to.

59/98 NLP APIs

Similarly, for Dialogflow to handle an end-user expression like that,

60/98 NLP APIs

it needs to be provided with context to correctly understand an intent.

61/98 NLP APIs
62/98 NLP APIs
63/98 NLP APIs

input and output contexts.

Input and output contexts are applied to intents.

They work together to control conversation flow:

64/98 NLP APIs

Output contexts control active contexts.

When an intent is matched, any configured output contexts for that intent become active.

65/98 NLP APIs

Input contexts control intent matching.

While contexts are active, Dialogflow is more likely to match intents with the currently active contexts.

66/98 NLP APIs

Use the same reminder example, you asks to set up a reminder.

67/98 NLP APIs

Dialogflow matches your expression to the SendReminder intent.

68/98 NLP APIs

This intent has a Reminder output context and it becomes active.

69/98 NLP APIs

Based on the Reminder output context, Google Assistant asks what the reminder is.

70/98 NLP APIs

You responds with “Mom’s birthday on May 1”.

71/98 NLP APIs

Dialogflow matches your expression to the AddtoCalendar intent,

72/98 NLP APIs

which is also a match to the Reminder input context.

73/98 NLP APIs

At the same time, the AddtoCalendar intent activates another output context called Calendar.

74/98 NLP APIs

Based on the Calendar output context, Google Assistant asks whether you want to add the reminder to Google Calendar, and the conversation goes on.

75/98 NLP APIs

To put all the pieces together, let’s look at how Dialogflow works.

76/98 NLP APIs

Please note that, by default, your agent responds to a matched intent with a static response.

77/98 NLP APIs

If you use one of the integration options,

78/98 NLP APIs

you can provide a more dynamic response by using fulfillment,

79/98 NLP APIs

meaning self-defined actions.

80/98 NLP APIs
  1. An end user starts a conversation by either typing or speaking.

81/98 NLP APIs
  1. Dialogflow matches the expression of the end user to an intent and extracts entities.

82/98 NLP APIs

3/4/5.

If you have self-defined fulfillments, Dialogflow sends a message to the webhook service, queries the database, and gets a response.

83/98 NLP APIs
  1. Dialogflow sends the response to the end user.

84/98 NLP APIs
  1. The end user sees or hears the response.

85/98 NLP APIs

In addition to the Dialogflow API, Google also provides the Natural Language API and the Healthcare Natural Language API.

86/98 NLP APIs

Natural Language API uses powerful pre-trained models and allow developers to easily apply natural language understanding (NLU) to their applications.

87/98 NLP APIs

The key features include

88/98 NLP APIs

sentiment analysis,

89/98 NLP APIs

entity analysis,

90/98 NLP APIs

entity sentiment analysis,

91/98 NLP APIs

content classification,

92/98 NLP APIs

and syntax analysis.

93/98 NLP APIs

The Healthcare Natural Language API helps you gain real-time analysis of insights stored in unstructured medical text.

94/98 NLP APIs

It lets you distill machine-readable medical insights from medical documents,

95/98 NLP APIs

and AutoML Entity Extraction for Healthcare makes it simple to build custom knowledge extraction models for healthcare and life sciences apps and doesn’t require coding skills.

96/98 NLP APIs

Try the demo yourself to better understand what the Natural Language API can do.

97/98 NLP APIs

In addition to the pre-built APIs,

98/98 NLP APIs

Google offers two other ways to develop an NLP project.