Dialogflow how to make a flow start the conversation and suggestion chips - chatbot

I have been trying to make my own chatbot with dialogflow CX,
I cant see to find enough DOC about this tool.
I am trying to make the bot start the conversation when i join the session but i cant find a way to do it.
Right now my chatbot needs a "hello" or some training word to start the dialog, but i want the chatbot to start this.
I think you can do it with "Custom payload" but i cant find an example of how to do it.
Also i know in DialogFlow ES you had a "Suggestion Chip" option where you could put in a button the answer options,
but i cant find it on CX, do i have to code it now?, can any kind hearth give me an example or extra documentation about how to code this bot?
Pd: I am new and learning how to do this chatbot, google cloud and object programming need advice in general, thanks!
Right now i am using https://cloud.google.com/dialogflow/cx/docs official doc

custom buttons with hints/suggestions as you outline in your question are only available in Dialogflow CX for integrated services. You can find information about which service is supported on this page. Otherwise, if you are able, you can develop your own integration through their API, i'm using the Python one.
If you decide, for example, to activate the Messenger integration to make your bot available via FB Messenger, you can visit the specific page and find, for example, that buttons can be set up this way.
There are many other response types, you can browse them in the same page (list, button, description, image, card): for each of them google provides a sample code to put in the "Custom Payload" box for the fulfillment. For example a box to www.yoursite.org would work like this:
{
"richContent": [
[
{
"type": "button",
"icon": {
"type": "chevron_right",
"color": "#FF9800"
},
"text": "Button text",
"link": "https://yoursite.org",
"event": {
"name": "",
"languageCode": "en",
"parameters": {}
}
}
]
]
}
by specifying "parameters" or "event" you can trigger Dialogflow events to manage the conversation flow.
Hope this made things clearer for you!

Related

Dialogflow Facebook messenger webhook - TTS response

I integrated my Dialogflow chatbot with Facebook Messenger and I was so far able to successfully send custom text and audio files from my node.js webhook.
The problem is that in order to send audio it must be online and I have to provide its URL. Something like this:
{
"payload": {
"facebook": {
"attachment": {
"payload": {
"url": "https://actions.google.com/sounds/v1/alarms/bugle_tune.ogg"
},
"type": "audio"
}
}
},
"platform": "FACEBOOK"
},
My main goal is to be able, based on a decision that I make, to choose whether to send the response back to Messenger as text or as text-to-speech of the usual text response.
For Example: if the user says hi and the chatbot should answer by "hello", I want based on certain conditions to be able to either forward the "hello" as text or to send it as a vocal message (ssml or text to speech).
Based on my search I'm kind of convinced that fulfillment payloads for facebook do not include the SSML type. If true, is there a turnaround solution for my problem? Is there another way to send text-to-speech?
(The platform doesn't necessarily have to be Facebook, but should be feasible to integrate with Dialogflow)

Watson Assistant programmatic to Heroku webhook not working

I have created a Webhook (https://moviebotdf.herokuapp.com/get-movie-details), it is tested with postman and dialogflow and working properly.
I want to integrate it with IBM Watson Assistant via programmatic call, but this is not returning anything (i.e. the output is "").
I checked the IBM support (https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-actions&locale=en) and also other solutions as calling a function that could call the webhook but I am having even less succcess there. As I understand from the support, a direct call from the Assistant to the Webhook should be possible (and easier for newbies like me), hence is the solution I seek. Code in the Assistant is as follows:
{
"context": {
"skip_user_input": true,
"prodname": "$prodname"
},
"output": {
"text": {
"values": [
"$dataToSend"
],
"selection_policy": "sequential"
}
},
"actions": [
{
"name": "https://moviebotdf.herokuapp.com/get-movie-details",
"type": "client",
"parameters": {
"prodname": "$prodname"
},
"result_variable": "context.dataToSend"
}
]
}
So "prodname" is captured by Watson Assistant in the previous node (I checked that and it is working correctly) and sent to the Webhook. The variable used in the Webhook is also called "prodname". The expected output from the Webhook is stored in the variable "dataToSend", but as said above the answer in Watson is only "" as "$dataToSend" is "".
I tried also with "result_variable": "dataToSend" and "result_variable": "$dataToSend" without success, so what I guess is that the webhook is not being called...
I am new in the topic, so please do not hesitate to correct any problems in my post.
Thanks in any case in advance!
AdriĆ 
IBM Watson Assistant lists three different options of making a programmatic call from within a dialog node:
client: your app is in charge of calling out to the action
server or cloud_function: IBM Cloud Functions action is invoked from Watson Assistant
web_action: The web action of an IBM Cloud Functions action is invoked from Watson Assistant
If you host your webhook on IBM Cloud Functions, then Watson Assistant can directly call it. With your current hosting and client specified, your app is in charge. In that case your app needs to check that the context includes the information about a client action, extract that related metadata, invoke the webhook and send the data back to Watson Assistant.
I have written an example for such a client action for my Watson conversation tool. See that repo for instructions.

Turning on facebook messenger camera through Dialogflow chatbot

I created a chatbot on Dialogflow which informs the user about the names of the members of my (extended) family and about where they are the living. I have created a small database with MySQL which has these data stored and I fetch them with a PHP script whenever this is appropriate depending on the interaction of the user with the chatbot.
I have integrated this chatbot to Facebook Messenger. My question is the following:
Can I directly trigger the Facebook messenger camera to be turned on through Dialogflow (and without using any other front-end camera)?
The reason I want to turn on the camera is to allow the user to take a photo of himself/herself and then I will process the photo with some computer vision libraries to infer if this person at the photo is a family member of mine. Obviously, I can simply create another basic front-end where I will turn on a camera whenever e.g. an intent called 'Camera' is triggered but I was wondering if can do this directly on facebook messenger.
The json response that I am receiving at my back-end from Dialogflow contains only the following UI capabilities:
"surface": {
"capabilities": [
{
"name": "actions.capability.MEDIA_RESPONSE_AUDIO"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.WEB_BROWSER"
}
]
}
therefore my first impression is that turning on a camera directly through Dialoglfow (and Facebook Messenger) is not possible.
Am I right?
Well, you're right... but probably not for the reasons you think.
First, you're not going to be able to turn on the Facebook Messenger camera because you're not using Facebook Messenger. You're using the Google Assistant. Right now, the Google Assistant doesn't define a way to send an image to the Action you're interacting with. (It does work with Google Lens, but at this point, there is no way to get that to you.)
Second, you wouldn't actually "turn on" the camera. If the user sends you an image through the Messenger camera, you can process this by looking at the originalRequest field in the JSON you get on your fulfillment which should contain the message from Facebook which contains the image.

How to wrap an existing chatbot for Google Assistant (Google Home)

We have a chatbot for our website today, that is not build using Google technology. The bot has a JSON REST API where you can send the question to and which replies with the corresponding answers. So all the intents and entities are being resolved by the existing chatbot.
What is the best way to wrap this functionality in Google Assistant / for Google Home?
To me it seems I need to extract the "original" question from the JSON that is send to our webservice (when I enable fullfilment).
But since context is used to exchange "state" I have to find a way to exchange the context between the dialogflow and our own chatbot (see above).
But maybe there are other ways ? Can it (invoke our chatbot) be done directly (without DialogFlow as man in the middle) ?
This is one of the those responses that may not be enough for someone who doesn't know what I am talking about and too much for someone who does. Here goes:
It sounds to me as if you need to build an Action with the Actions SDK rather than with Dialog flow. Then you implement a text "intent" in your Action - i.e. one that runs every time the user speaks something. In that text intent you ask the AoG platform for the text - see getRawInput(). Now you do two things. One, you take that raw input and pass it to your bot. Two, you return a promise to tell AoG that you are working on a reply but you don't have it yet. Once the promise is fulfilled - i.e. when your bot replies - you reply with the text you got from your bot.
I have a sample Action called the French Parrot here https://github.com/unclewill/french_parrot. As far as speech goes it simply speaks back whatever it hears as a parrot would. It also goes to a translation service to translate the text and return the (loose) French equivalent.
Your mission, should you choose to accept it, is to take the sample, rip out the code that goes to the translation service and insert the code that goes to your bot. :-)
Two things I should mention. One, it is not "idiomatic" Node or JavaScript you'll find in my sample. What can I say - I think the rest of the world is confused. Really. Two, I have a minimal sample of about 50 lines that eschews the translation here https://github.com/unclewill/parrot. Another option is to use that as a base and add code to call your bot and the Promise-y code to wait on it to it.
If you go the latter route remove the trigger phrases from the action package (action.json).
So you already have a Backend that process user inputs and sends responses back and you want to use it to process a new input flow (coming from Google Assistant)?
That actually my case, I've a service as a Facebook Messenger ChatBot and recently started developing a Google Home Action for it.
It's quite simple. You just need to:
Create an action here https://console.actions.google.com
Download GActions-Cli from here https://developers.google.com/actions/tools/gactions-cli
Create a JSON file action.[fr/en/de/it].json (choose a language). The file is your mean to define your intents and the URL to your webhook (a middleware between your backend and google assistant). It may look like this:
{
"locale": "en",
"actions": [
{
"name": "MAIN",
"description": "Default Welcome Intent",
"fulfillment": {
"conversationName": "app name"
},
"intent": {
"name": "actions.intent.MAIN",
"trigger": {
"queryPatterns": [
"Talk to app name"
]
}
}
}
],
"conversations": {
"app name": {
"name": "app name",
"url": "https://your_nodejs_middleware.com/"
}
}
}
Upload the JSON file using gactions update --action_package action.en.json --project PROJECT_ID
AFAIK, there only a Node.js client library for Actions-on-google https://github.com/actions-on-google/actions-on-google-nodejs that why you need a Node.js middleware before hitting your backend
Now, user inputs will be sent to your Node.js middleware (app.js) hosted at https://your_nodejs_middleware.com/ which may look like:
//require express and all required staff to build a Node.js server,
//look on internet how to build a simple web server in Node.js
//if you a new to this domain. const {
ActionsSdkApp } = require('actions-on-google');
app.post('/', (req, res) => {
req.body = JSON.parse(req.body);
const app = new ActionsSdkApp({
request: req,
response: res
});
// Create functions to handle requests here
function mainIntent(app) {
let inputPrompt = app.buildInputPrompt(false,
'Hey! Welcome to app name!');
app.ask(inputPrompt);
}
function respond(app) {
let userInput = app.getRawInput();
//HERE you get what user typed/said to Google Assistant.
//NOW you can send the input to your BACKEND, process it, get the response_from_your_backend and send it back
app.ask(response_from_your_backend);
}
let actionMap = new Map();
actionMap.set('actions.intent.MAIN', mainIntent);
actionMap.set('actions.intent.TEXT', respond);
app.handleRequest(actionMap); });
Hope that helped!
Thanks for all the help, the main parts of the solution are already given, but I summarize them here
action.json that passes on everything to fullfilment service
man in the middle (in my case IBM Cloud Function) to map JSON between services
Share context/state through the conversationToken property
You can find the demo here: Hey Google talk to Watson

Chat bot platform

my boss give me the task to creata a chatbot, not made with Telegram or Slack, in which use Watson Conversation service.
More, the chat bot has to be inserted inside a web page, then it has to be embeddable in html as javascript.
Are there anyone who knows other good platforms to performe these tasks?
Thanks for any help.
After replying in comments and I had another look and realised Microsoft Bot Framework could work with minimal dev investment (in the beginning).
https://docs.botframework.com/en-us/support/embed-chat-control2/
This little guy is fun. You should give him a try.
http://www.program-o.com/
I strongly suggest you to build more an assistant than a simple bot, using a language understanding service tool like Microsoft LUIS, that is part of the Microsoft Cognitive Services.
You can then combine this natural language processing tool with bot SDK like MicroSoft Botframework mentioned above, so that you could easily run queries in natural language, parse the response in a dialog in entities and intents, and provide a response in natural language.
By an example, a parsed dialog response will have something like this json
{
"intent": "MusicIntent",
"score": 0.0006564476,
"actions": [
{
"triggered": false,
"name": "MusicIntent",
"parameters": [
{
"name": "ArtistName",
"required": false,
"value": [
{
"entity": "queen",
"type": "ArtistName",
"score": 0.9402311
}
]
}
]
}
]
}
where you can see that this MusicIntent has a entity queen of type ArtistName that has been recognized by the language understanding system.
that is, using the BotFramework like doing
var artistName=BotBuilder.EntityRecognizer.findEntity(args.entities, Entity.Type.ArtistName);
A good modern bot assistant framework should support at least a multi-turn dialog mode that is a dialog where there is an interaction between the two party like
>User:Which artist plays Stand By Me?
(intents=SongIntent, songEntity=`Stand By Me`)
>Assistant:The song `Stand by Me` was played by several artists. Do you mean the first recording?
>User:Yes, that one!
(intents=YesIntent)
>Assistant: The first recording was by `Ben E. King` in 1962. Do you want to play it?
>(User)Which is the first album composed by Ben E.King?
(intents=MusicIntent, entity:ArtistName)
>(Assistant) The first album by Ben E.King was "Double Decker" in 1960.
>(User) Thank you!
(intents=Thankyou)
>(Assistant)
You are welcome!
Some bot frameworks use then a WaterFall model to handle this kind of language models interactions:
self.dialog.on(Intent.Type.MusicIntent,
[
// Waterfall step 1
function (session, args, next)
{
// prompts something to the user...
BotBuilder.Prompts.text(session, msg);
},
// waterfall step 2
function (session, args, next)
{
// get the response
var response=args.response;
// do something...
next();//trigger next interaction
},
// waterfall step 3 (last)
function (session, args)
{
}
]);
Other features to consider are:
support for multi-languages and automatic translations;
3rd party services integration (Slack, Messenger, Telegram, Skype, etc);
rich media (images, audio, video playback, etc);
security (cryptography);
cross-platforms sdk;
I've started to do some work in this space using this open source project called Talkify:
https://github.com/manthanhd/talkify
It is a bot framework intended to help orchestrate flow of information between bot providers like Microsoft (Skype), Facebook (Messenger) etc and your backend services.
I'd really like people's input to see if how it can be improved.