Multiple Responses with Dialogflow (aka Api.ai) - chatbot

I'm trying to create a chatbot which once "greetings" process is done goes on and initiate a new topic without any user query. It has to be something like the following:
bot : hello
user : hello
bot : how old are you?
user : 35
bot : Great.
bot : Let's talk about politics. Are you american?
Until the "great" line everything works but then I cannot trigger the event that will prompt the line "Let's talk about politics...."
The doc is vague, can I do this without webhooks? And if not, how would a webhook like this look like?

You can define multiple responses in Dialogflow's console as seen in the screenshots below by clicking the Add Message Content button in the response section of the intent you'd like to add the response to. You can also send multiple messages for some platforms (depending on platform feature availability) with webhook fulfillment using rich messaging responses documented here: https://dialogflow.com/docs/rich-messages
Go to the response section of the intent you'd like to add a 2nd response to:
Click ADD MESSAGE CONTENT and select Text response:
Enter you second message in the second text box provided:

Yes, you can define multiple responses. If you are planning to use Facebook Messenger platform to show the responses you can use the code below. Change "Response 1" and "Response 2" to your desired text and dump the my_result object as json and return it back. You need to change the "platform" if you want to use any other platforms than messenger.
my_result = {
"fulfillmentMessages": [
{
"text": {
"text": [
"Response 1"
]
},
"platform": "FACEBOOK"
},
{
"text": {
"text": [
"Response 2"
]
},
"platform": "FACEBOOK"
}
]
}

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)

End Google Assistant Conversation

I have an application that communicates with Google Assistant via Webhook. When a user asks for something, my app sends the question to AI (Watson IBM). After it gets the response, I want to show it to the user and end the conversation. So I send a text from Watson and nextSecene =actions.scene.END_CONVERSATION. But Google Assistant just ends the conversation without showing the response to user. So is it possible to show the response message to the user and than end the conversation?
Example of my app JSON format response:
GAResponse(prompt=GAPrompt(override=false, firstSimple=GAFirstSimple(speech=<speak>You are very smart bro,y<break time="100ms"/> and i love monsters like you.</speak>, text=You are very smart bro and i love monsters like you), content=null, lastSimple=null, link=null, canvas=null, orderUpdate=null), scene=GAScene(name=null, slotFillingStatus=null, slots=null, next=actions.scene.END_CONVERSATION) ...)
Yes this is possible.
I'm not sure which library your using to generate your response json, but below is an example that provides the speech and text data and ends the conversation. You can learn more on the fulfillment (aka webhook) on the reference documentation
{
"session": {
"id": "example_session_id",
"params": {}
},
"prompt": {
"override": false,
"firstSimple": {
"speech": "<speak>You are very smart bro, <break time="100ms"/> and i love monsters like you.</speak>",
"text": "You are very smart bro and i love monsters like you"
}
},
"scene": {
"name": "SceneName",
"slots": {},
"next": {
"name": "actions.scene.END_CONVERSATION"
}
}
}
If you're interested in using Assistant Conversation libraray, check out this link to see an example response

Webhook integration with Watson Assistant?

I want to know whether IBM Watson Assistant has the feature of calling webhook.
It means when an intent of workspace is matched Watson Assistant need to send a post request to an external server including the intent in the request body.
Example for a webhook:
https://123.456.789.12:7788/myWebhook/testMethod
IBM Watson Assistant need to send a Post request to this service and that service will return a text string. Watson Assistant should get that text and show it to the user.
That is my usecase. Will it work with Watson Assistant?
i found the below documentation from IBM site.
https://console.bluemix.net/docs/services/conversation/dialog-actions.html
It says to update the json response. i.e. add another key value pair to json object as "action". in the action json array there is "name" parameter. I added above url to name parameter and checked by calling the intent whether a request comes to my web service but it didn't.
following is my json response. i assumed once the intent is matched a post request should go to my web service. but i checked my web service by printing the request body on the console. but no any request came to it. could you please tell me where did i miss?
{
"context": {
"skip_user_input": true
},
"output": {
"text": {
"values": [
"your current outstanding balance is $my_balance ."
],
"selection_policy": "sequential"
}
},
"actions": [
{
"name": "https://123.456.789.12:7788/myWebhook/testMethod",
"type": "client",
"parameters": {
"body": "$body"
},
"result_variable": "context.my_balance"
}
]
}
You found the correct method, i.e. dialog actions, to implement webhooks.
Watson Assistant supports server- or client-side actions:
For the server-side action you would set up an action with IBM Cloud Functions. That action would call the webhook.
For client side, you would pass the information similar to what you show in the question to the app (client). Your app would need to react and to call the webhook.
From what I read about your case I recommend checking out the server-side action. This tutorial about a database-driven bot implements a couple of those actions. Instead of calling the database, you would call out the webhook.
As of August 2019, there is now an integrated webhook feature in Watson Assistant.
Go to "Options" in the Assistant dialog and enable webhook. Paste the url you got after creating an action from cloud functions. Don't forget to add ".json" to the url you paste in the assistant webhook page. See more information here:
https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-webhooks

How to add a new line in IBM Watson chatbot conversation?

Currently I'm working with the chatbot service provided by the IBM Watson Coversation api. Now I'm facing a problem, related to adding a new line in the text reply from the chatbot. Can anyone tell me how to do this?
in this case, you can use HTML for that, inside conversation flow with <br>.
Check my example:
You can see that does not work in "Try it out":
But if you open with a browser, you see that work:
Check JSON example:
{
"output": {
"text": {
"values": [
"Hey, <br>Can I help you?",
"",
""
],
"selection_policy": "random"
}
}
}
You can use other tags, example: <button>, <id>, etc.

How to get the text of message, when quick reply is tapped in facebook messanger bot?

Question related to API.AI Bot , Facebook Messanger
When a Quick Reply is tapped, a text message will be sent to your webhook Message Received Callback. The text of the message will correspond to the title of the Quick Reply, when the content type is 'text'. How can we get the text of message! when the content type is 'location'?. It is mentioned that when we use location quick reply, we don't add title field. so how can we get a text message without using title?
I am unable to call webhook, due to not getting text of the message.
Please help me out. I am stuck from last 2 days.
You can manipulate with ChannelData.
hehe I got your Problem
I hope you know the responses coming from webhook if not here is sample responses
responses for quick_reply with type text
"message": {
"quick_reply": {
"payload": "productId-12345678"
},
"mid": "mid.$cAAFXVKjn1KtjtBAtHFdgsrkbGWwm",
"seq": 15453,
"text": "buy this"
}
responses for quick_reply with type location
"message": {
"mid": "mid.$cAAFXVLGKMJ1jtApB51dgsTnITNet",
"seq": 25413,
"attachments": [
{
"title": "Hi-tech city Hyderabad",
"url": "https://l.facebook.com/l.php?u=https%3A%2F%2Fwww.bing.com%2Fmaps%2Fdefault.aspx%3Fv%3D2%26pc%3DFACEBK%26mid%3D8100%26where1%3DHyderabad%2B500081%26FORM%3DFBKPL1%26mkt%3Den-US&h=ATPXrPSDsyApPyqD9ozWt82dL9M28VZPQCqmICpsmBfXY0BCffiP4ychQ36sSWUNNBOeiJZq8tq8DLF7-A0_7VViPwwC64LM1XR-uAUN0sXdcgP5rDg&s=1&enc=AZPs1nCI5B8J4s27b7zAJKJDYaa2KSlhxQ5ppN30fb5lI3KUFcnQlSn_g4796j3p4ShwnzPvRyqXS470lEluzN06",
"type": "location",
"payload": {
"coordinates": {
"lat": 17.44521051,
"long": 78.38363399
}
}
}
]
}
as you can see that in text type quick_reply we are getting the previous context as text to which user respond and we can use respective payload for processing. This is what facebook try to incorporate context of chat for a single time for quick reply they havnt incorporated this to other may be because of frequent use of context in case of text quick_reply rather than location.
Now the things which you are wondering about is context . Yes you need to maintain context of chat and thats how a real bot thing came into picture. you can maintain context of chat using many free nlp engine like wit.ai , api.ai and other