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
Related
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)
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!
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"
}
]
}
In api.ai,
Rich formatting is supported for skype pretty fine. Here's an example:-
Here's the code of custom payload of api.ai:-
{
"skype": {
"text": "OCAS means Online Credit Approval System.\n Click [here] (http://www.erainfotechbd.com/product/ocas-online-credit-approval-system/) for more information. ",
"attachments": [
{
"contentType": "image/png",
"contentUrl": "http://weknowyourdreams.com/images/smile/smile-07.jpg",
"name": "Profile-picture.png"
}
]
}
}
Now, I wanna do something like this in facebook messenger also. But in the api.ai doc, only audio, video and file is supported.
Is there any other way to do so for url also in messenger ?
Generally webhook responses can deliver any custom payload to most platforms that API.AI supports, so any feature supported by Facebook Messenger, Skype, Google Assistant, etc. can be utilized through API.AI. Unfortunately Facebook doesn't seem to support hyperlinked text. The closest analog I could find is a what Facebook calls a URL Button. Below is an example of how you could create a API.AI response that has a Facebook URL Button with Facebook's Button template:
{
"speech": "OCAS means Online Credit Approval System. Check your phone for more information.",
"displayText": "OCAS means Online Credit Approval System. Click here for more information: http://www.erainfotechbd.com/product/ocas-online-credit-approval-system/",
"data": {
"facebook": {
"attachment": {
"type": "template",
"payload": {
"template_type": "button",
"text": "OCAS means Online Credit Approval System",
"buttons": [
{
"type": "web_url",
"url": "http://www.erainfotechbd.com/product/ocas-online-credit-approval-system/",
"title": "Click here for more information"
}
]
}
}
}
}
}
You can use also use any other Facebook Messenger APIs by including any JSON inside the "message" attribute that you see from Facebook's Messenger documentation and it will be passed along to Facebook by API.AI
PS - the code above should produce a message that looks something like this:
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