πŸ€–Nulu Business
Google
Dialogflow

🌐 Google Dialogflow

The settings below are related to the Nulu AI app.

πŸ”„ Synchronization

To start using the Google AI services and Dialogflow follow the steps below.

  1. Enable the setting Nulu AI > Settings > Nulu AI > Google > Dialogflow Chatbot and save the changes. πŸ’Ύ
  2. Go to Google Cloud Console (opens in a new tab) and sign in. πŸ”‘
  3. Select or create a project by clicking the Select a project button on the top-left. Name the project as you want. πŸ†•
  4. Activate the Dialogflow API by entering Dialogflow API on the top search bar. Click Dialogflow API and then click Enable. βš™οΈ
  5. Select the project and go to Left menu > APIs and services > OAuth consent screen. Select External and click Create. πŸ“
  6. In App name enter what you want, in User support email and Developer contact information enter your email. Click Save and continue. πŸ’¬
  7. In the scopes area, click Add or remove scopes, scroll bottom and into the Manually add scopes area enter https://www.googleapis.com/auth/dialogflow,https://www.googleapis.com/auth/cloud-language,https://www.googleapis.com/auth/cloud-translation. Click Add to table and then Update and Save and continue. πŸ“‹
  8. In the test users area, click Add users and add your Google email, use the same email as the currently logged in account. Click Save and continue. πŸ“§
  9. Go to Left menu > APIs and services > Credentials and click Create credentials, select OAuth client ID. As Application type select Web application. Enter any name you want. In Authorised redirect URI enter the redirect URL, get it from Nulu AI > Settings > Nulu AI > Google > Authorised redirect URI. Click Create. πŸ”
  10. Copy Client ID and Client Secret and paste them into Nulu AI > Settings > Nulu AI > Dialogflow. Save the settings. πŸ“‹
  11. In Settings > APIs & Services > OAuth Consent Screen click PUBLISH APP. There is no need to complete the review process, leave it in the pending review state. πŸ“£
  12. Click Nulu AI > Settings > Nulu AI > Google > Synchronize. Login with the same Google account you have used till now. On the next screen click Continue. On the next screen select all scopes and click Continue. πŸ”„
  13. Copy the Refresh token and paste it into Nulu AI > Settings > Nulu AI > Google > Refresh token. πŸ†”
  14. You are done! If you want to activate the Dialogflow chatbot, check Settings > Nulu AI > Google > Dialogflow chatbot. Also, you have to enter your chatbot Project ID or Agent Name. Note that the app does not need to be approved by Google. πŸŽ‰
  15. If you are a Google Workspace user, go to Google Workspace Admin (opens in a new tab) and click Google Cloud Session control. Set Re-authentication policy to Never require re-authentication. πŸ”

πŸ€– Dialogflow

The information provided below is relevant to Dialogflow.

πŸ†” Get Project ID

  1. Log in to the Dialogflow ES console (opens in a new tab). You must sign in with the same Google account used during the synchronization.
  2. Click the gear icon at the top left, near the chatbot name, and open the settings area. If you haven't created a chatbot yet, follow the instructions below to create your first bot.
  3. Copy the Project ID. πŸ“‹
  4. Make sure to choose US / GLOBAL on the top left of the Dialogflow dashboard. Please note that our system does not support mega agents. 🌍

πŸ†” Get Dialogflow CX Agent Name

  1. Log in to the Dialogflow CX console (opens in a new tab).
  2. Select the project of the desired agent and go to the agents page. You can enter the agents page by selecting the agent and by clicking the top button Agents > View all agents. πŸ‘€
  3. Click the options menu for the desired agent and click Copy name. πŸ“‹

More details at Dialogflow CX Quickstart (opens in a new tab).

🌍 Location

Set the location or region of your Dialogflow agent. This setting is optional if your agent location is set to global. 🌐

πŸ™Œ Welcome Intent

Trigger the Dialogflow Welcome Intent for new visitors. The option Settings > Messages > Welcome message must be active. πŸŽ‰

πŸ“§ Send the user details

Send the user details of the registration form and email rich messages to Dialogflow. πŸ“¬

πŸ’Ύ Add Intents to saved replies

Include the Dialogflow Intents into the saved replies. To access the saved replies option, go to Settings > Admin > Saved replies. πŸ“

πŸ€– Create a basic chatbot

If you haven't created a chatbot yet, follow the instructions below to create your first one. The creation and management of your Dialogflow chatbot is handled entirely by Dialogflow. There are a lot of tutorials online that can help you create and configure your Dialogflow bot.

  1. To create your first chatbot enter the Dialogflow console and create an agent. As Google project select the same project used during the synchronization.
  2. Add a new Intent from the left menu and open it.
  3. In the Training phrases area, add the user's question you want the chatbot to reply to, add as many variants as you can. For example, if you want the chatbot to reply to users asking for your business address, add variants like "what is your address", "address", "where are you". πŸ—£οΈ
  4. In the Responses area, add the chatbot answer as a text response. If you want to add buttons, cards, etc., you can use the rich messages. πŸ’¬
  5. You have created your first question and answer! Test it from the right area or from the Nulu AI chat. Add new Intents to populate your chatbot with the questions and answers you want. You can include basic pre-built questions and answers by enabling the Small Talk feature from the left menu. πŸŽ‰

Here are some great resources to help you build a more complex chatbot:

πŸ”§ Actions

The following actions give the chatbot the ability to interact with the website autonomously on behalf of the user. To use an action go to Dialogflow, edit an Intent, and add a new Custom Payload response with the following syntax: { "ACTION-NAME": ACTION-VALUE }.

Action codeDescription
{ "human-takeover": true }Disable the chatbot for 5 minutes, notify agents, and leave the conversation marked as unread.
{ "disable-bot": true }Disable the chatbot for 5 minutes.
{ "redirect": "URL" }Redirect the user to the given URL. Add the value "new-window": true to open the URL in a new window.
{ "open-article": ID }Open the article with the given ID.
{ "transcript": true }Generate the conversation transcript as a text file and download it. Set it to email to send the transcript to the user's email, add the value message: "Your message" to include a message in the email.
{ "tags": ["Tag 1", "Tag 2"] }Assign tags to a conversation.
{ "department": ID }Change or set the conversation department and notify the agents.
{ "agent": ID }Change or set the agent assigned to the conversation and notify the agent.
{ "send-email": { "recipient": "active_user", "message": "", "attachments": [] } }Send an email to the active user or agents. Attachments syntax: [["name", "link"], ["name", "link"],...]}. Recipient value can be active_user or agents.
{ "update-user": true }Tells the admin area to update the user of the active conversation. Use this action in combination with other actions to

update the user details of the admin area in real-time. | | { "archive-chat": true } | Archive the chat and send the close message if active. | | { "update-user-details": { "email": "", "last_name": "", "first_name": "", "extra": { "phone": ["+123456789", "Phone"] }}} | Update the details of the active user. You can update all details, including first_name, last_name, email, user_type, password. You can update the user extra details, like the phone number, by entering the values into the extra key, the values must use the following syntax: "slug": [value, "label"]. Download an example here. To upload an Intent go to the Intents area and click the 3-dots menu icon on the top-right, then click Upload Intent. Start the conversation by sending the message "start". | | { "update-user-language": "$language" } | Update the user language, and the chatbot language if multilingual chatbots feature is active, to match the language requested by the user. The Dialogflow Entity value for the language is represented by the parameter $language. |

🌐 Dialogflow Fulfillment

The fulfillment data sent to your webhook URL is like below:

{
	"responseId": "4a58fc4f...",
	"queryResult": {
		"queryText": "fullfilment",
		"parameters": [],
		"allRequiredParamsPresent": true,
		"fulfillmentText": "Example",
		"fulfillmentMessages": [{
			"text": {
				"text": ["Response"]
			}
		}],
		"outputContexts": [{
			"name": "projects/schiocco...",
			"parameters": {
				"no-input": 0,
				"no-match": 0
			}
		}],
		"intent": {
			"name": "projects/schiocco...",
			"displayName": "Fullfilment"
		},
		"intentDetectionConfidence": 1,
		"languageCode": "en"
	},
	"originalDetectIntentRequest": {
		"payload": {
			"support_board": {
				"conversation_id": "3002",
				"user_id": "3777"
			}
		}
	},
	"session": "projects/example/agent/sessions/3777-3002"
}

The payload and session fields contain the Nulu AI user ID and conversation ID.

🧠 Dialogflow Information

πŸ”„ Chatbot training and optimization

It will require some time for your chatbot to consistently provide correct answers to all questions. To improve its performance, you and your human agents should continuously train the chatbot by incorporating new question variations and Intents. This approach will effectively enhance the capabilities of your chatbot. πŸŽ“

Agents can add new Intents and chatbot responses, and add new training phrases to existing intents on the fly from the admin area by moving the mouse cursor over a message and clicking the Dialogflow Intent icon. Enable Settings > Nulu AI > Nulu AI > Generate user expressions to automatically add variations of the question and to rewrite the answer. New Intents will contain also the responses, while the update of existing intents will add new training phrases only, but not new chatbot responses. If you're using Dialogflow CX, the chatbot responses will be added to the latest flow used in the conversation if any, otherwise to the start flow.

If the chatbot is replying with the wrong intents, go to Dialogflow Console > chatbot Settings > ML Settings, and set the ML CLASSIFICATION THRESHOLD to a larger number, such as 0.6. Also check the Intent detection confidence. πŸ“Š

🧠 Dialogflow Intent detection confidence

When searching for a matching intent, Dialogflow scores potential matches with an intent detection confidence, also known as the confidence score. These values range from 0.0 (completely uncertain) to 1.0 (completely certain). Specify a value ranging from 0.1 to 1.0. Any answer provided by Dialogflow that is less than this value will not be considered. If you are utilizing Dialogflow alongside your Nulu AI chatbot that is trained using your resources, it is recommended to configure the value as 0.81. βš–οΈ

πŸ“š Knowledge Base

Knowledge Base are automatically enabled. Knowledge Base is a feature that gives your chatbot the ability to search within documents (such as a PDF) or web pages to find an answer. To create your first Knowledge Base, go to Dialogflow Knowledge Connectors (opens in a new tab) πŸ“„

πŸ“‹ Dialogflow response

The full Dialogflow JSON response is automatically saved in the database, sb_messages, column payload. πŸ’Ύ

πŸ” Ignore an Intent if it doesn't fit the provided keywords

Sometimes Dialogflow gives incorrect answers due to similar questions with different subjects. To solve this, you can instruct Nulu AI to ignore an Intent if specific keywords are not present in the user's message. Here's how you can do it:

  1. Enter Dialogflow and edit the Intent.
  2. For each training phrase, select the keywords you want to be required and link them to a new Entity, or an existing one.
  3. Under Actions and parameters check Required and add a new Prompt with value skip-intent.
  4. Save the Intent. πŸ’Ύ

πŸ“Ž User attachments

User attachments are sent to Dialogflow by appending the attachments to the message details in the following format:

[name:file-name.ext,url:URL,extension:file-extension]

Example:

[name:archive.zip,url:https://board.support/archive.zip,extension:zip]
[name:license.pdf,url:https://board.support/license.pdf,extension:pdf]

πŸ“Ž Chatbot attachments

To allow the chatbot to send attachments, add a Custom Payload response and insert this JSON code:

{ "attachments": [["name", "YOUR-LINK"], ["name", "YOUR-LINK"], ["name", "YOUR-LINK"]]}

Replace "name" with the actual name of the attachment to display and replace "YOUR-LINK" with the actual URL of the file. Images attachments are displayed automatically as images. πŸ“Έ

πŸ’¬ Rich messages

To allow Dialogflow to send rich messages, simply enter the rich message shortcode into the TEXT RESPONSE field or add a new Custom Payload response and insert this JSON code: { "rich-message": "shortcode" }. Replace "shortcode" with the rich message shortcode, to have a valid JSON code you need to replace all " chars with \". To obtain the shortcodes or to learn how to create a rich message, please click here. πŸ’¬

πŸ’¬ Rich message response

When the user interacts with rich messages via the Nulu AI chat (e.g. by clicking a button), the rich message response is sent to Dialogflow in the following format: ID|response, or ID if the rich message type is registration, email, follow up, in this case, the rich message values are sent as array in the queryParams['payload'] key. ID is the rich message ID, which can be set by adding the attribute id="YOUR-ID" to the shortcode. If no ID has been set, a random ID will be used instead. response is the input or selection of the user. To block Dialogflow from replying to a rich message add a new intent with ID as the only user expression and no response.

If the user is interacting with the chatbot via a messaging app (e.g. WhatsApp), the response of the rich message does not contain the rich message ID and Dialogflow contexts must be used to allow Dialogflow to understand which Intent to activate for a specific rich message response. πŸ’¬

πŸ“ Get rich message response for registration, email, follow up

  1. Check the option Nulu AI > Settings > Nulu AI > Google > Send user details. πŸ“§
  2. From Left menu > Fulfillment enable Webhooks, you only need to enter the URL of the file that will receive the Dialogflow webhook data.
  3. Create an Intent with the ID of the rich message, for the registration form, enter registration, for the follow up form enter sb-follow-up-form, for email forms enter email.
  4. Enable the Fulfillment for the Intent. βœ…

You're done! The file of the webhook URL will receive the Nulu AI rich message user details. πŸ“§

πŸ“ Sequential survey

To create a sequential survey like the one in the demo you need to enter the Rich message ID in the Training phrases, check the example below.

  1. Go to Dialogflow and create a new intent. In the Training phrases area enter the user expression survey example. In the Responses area enter the code [buttons id="test-survey-1" options="Software,Physical products,Services" title="What is your type of business?" message="Please choose the type that best suits your company." success="Your company type is "]. πŸ—£οΈ
  2. Create a new intent. Enter the user expression test-survey-1 and as response enter [select id="seq-survey-2" options="Priority post, Express courier, International courier" title="Shipping methods" message="Choose the preferred shipping method of your customers" success="Your customers preferred shipping method is"]. πŸ—£οΈ
  3. Create a new intent. Enter the user expression test-survey-2 and as response enter Thank you for completing our survey!. πŸŽ‰

You're done. βœ…

πŸ”— Department linking

Get the department

IDs from Settings > Miscellaneous > departments. 🏒

Get the project IDs from the Dialogflow settings area of your agents. πŸ†”

πŸ“‘ More information

  1. Dialogflow supports the use of voice messages through speech recognition. WhatsApp audio messages and .ogg audio files are not natively supported. To support WhatsApp audio messages and .ogg audio files, activate Settings > Nulu AI > Nulu AI > Speech recognition. πŸŽ™οΈ
  2. You can activate the chatbot via API by sending a message with no text and payload { "event": "activate-bot" }. βš™οΈ
  3. The following details are sent to Dialogflow in the queryParams parameter when detecting an intent: conversation_id, user_id. πŸ“‹
  4. To trigger the welcome event in Dialogflow CX, create an Event Handler and insert Welcome as Custom Event. πŸŽ‰
  5. Nulu AI articles are synchronized automatically with the Dialogflow knowledge base. πŸ“š
  6. Use the JS variable SB_DIALOGFLOW_AGENT = "AGENT ID" to change the default Dialogflow agent, replace "AGENT ID" with the project ID. πŸ› οΈ
  7. If the user sends the same message again, triggering the same Intent in Dialogflow, and Nulu AI is active, Nulu AI will attempt to send a message from Nulu AI and will ignore the response from Dialogflow. πŸ”„
  8. You can access the user_id and conversation_id of the current user and conversation in Dialogflow CX using the $session.params.user_id and $session.params.conversation_id codes, which are located in the Condition area of the route. πŸ“‹

🌐 Multilingual Chatbot

The feature Nulu AI > Google > Multilingual checks if there is a Dialogflow agent in the user's language and activates it. 🌍

For this feature to work the user language must be known. The user language is based on the language user detail of the user if set, otherwise on the user browser language. The language can also be detected with the language detection feature. 🌐

Make sure to activate this setting even if your Nulu AI sources consist of multiple languages. βœ…

🌍 Automatic Translation

The automatic translation feature automatically translates user messages into agent language and agent messages into user language. To enable it check the option Settings > Nulu AI > Automatic translation and complete the synchronization process. The multilingual via translation feature also requires these steps. 🌍

The Google account used for the Dialogflow synchronization must have billing and the cloud-translation service enabled, to do that follow the steps below:

  1. Log in to Google Cloud Console (opens in a new tab) with your Google account and select the project of your Dialogflow Agent. πŸ”‘
  2. On the top search bar type cloud translation, select the Cloud Translation API service and enable it. Please note that this is a paid service with a free tier, additional charges may occur. πŸ’³
  3. Enable the billing by clicking Left menu > Billing and by enabling a billing account with a valid payment method. Enable billing for the project of your Dialogflow agent. πŸ’³

πŸ“š Information

  1. The user messages in the admin area are translated automatically in real-time to match the agent language. 🌐
  2. The agent messages are translated automatically in real-time to match the user language. 🌐
  3. Agents can view the original message by opening the message menu and by clicking View original message. πŸ“„
  4. The agent language is based on the language user detail of the agent if set, otherwise on the browser language, or admin area language. πŸ—£οΈ
  5. The user language is based on the language user detail, if set, otherwise on chat language, if set, otherwise on the browser language. The language can also be detected with the language detection feature. 🌐
  6. The notifications are also translated. πŸ””
  7. To avoid translating a string, enclose it with the characters ` or `` ```. πŸ“‹

🌍 Multilingual via translation

The feature at Settings > Nulu AI > Multilingual via translation automatically translates user messages into the default language of Dialogflow or Nulu AI, and translates Dialogflow or Nulu AI messages into the language spoken by the user. Additionally, this feature translates all text displayed within the chat, such as the chatbot's rich messages, registration forms, and pop-up notifications. To enhance performance and minimize translation costs, the translations are automatically integrated into the translation files. Combine this feature with the language detection feature for optimal results. 🌐

The original texts must be in English. πŸ“„

🌐 Language detection

Detect the language of the user's messages and change the user language and Dialogflow agent language accordingly, if available, otherwise, show a fallback message. You can use the following merge fields in the message: {language_name}. 🌍

  • The user message must be at least 2 words long. πŸ—£οΈ
  • Language detection is executed only for the first 2 user messages of a conversation. πŸ”„
  • As long as the Nulu AI chatbot is operational and programmed to respond to generic inquiries, the fallback message will never be dispatched, since Nulu AI will consistently provide answers to any use message. 🧠

πŸ” Google search

The Google search features give your chatbot the ability to search for answers on Google and your website and automatically correct misspelled user questions. To start using it, follow the steps below. πŸ”

  1. Register at Google Programmable Search Engine (opens in a new tab). πŸ”‘
  2. Create a search and set it up as you want. We recommend adding only your website and Wikipedia if you want your chatbot to reply to general questions, leave disabled the option Search the entire web. Use the setting Entities to exclude invalid results. πŸ› οΈ
  3. Go to Edit search engine > Setup > Basic and copy the Search engine ID value, paste it in Nulu AI. πŸ“‹
  4. To get the API key visit Google Custom Search API (opens in a new tab) and click Get a key. πŸ”‘

βœ… Spelling correction

In the case where Dialogflow is unable to find the appropriate response to the user's message, this function verifies if there are any spelling errors. If any such errors exist, Dialogflow is prompted again with the correctly spelled version of the message for an accurate response. Although it has a lower priority, this feature can still work together with the Nulu AI Dialogflow spelling correction feature. βœ…

πŸ™οΈ Entities

The Entities setting analyze the user's message and recognize and extract entities like cities, events, dates, and more. Use it to exclude invalid results returned by Google search. To enable this setting follow the steps below. πŸ™οΈ

  1. Log in to Google Cloud Console (opens in a new tab) with your Google account and select the project of your Dialogflow Agent. πŸ”‘
  2. Enter Cloud Natural Language API in the search bar at the top, select Cloud Natural Language API and enable the API. βš™οΈ
  3. Enable the billing by clicking Left menu > Billing and by enabling a billing account with a valid payment method. Enable billing for the project of your Dialogflow agent. πŸ’³

πŸ“š Information

  1. The Google search is performed only if the chatbot does not know the answer to the user's question and if the length of the user's message is greater than 4 characters. πŸ“
  2. If the Google search returns a result, the Dialogflow context google-search is automatically activated. The context contains the attribute link which is the website's link of the Google search result. Use the context to create a new intent that provides the link, if the user sends a message like tell me more or I want to know more. πŸ”—
  3. Google Search is not required to activate the spelling correction. You can disable Google Search and activate only spelling correction. βœ…
  4. If Google Search is active, it will have priority over Nulu AI. πŸ†