How to annotate System Entities in Dialogflow API? - dialogflow-es

We are using the Dialogflow API to export entities into Dialogflow.
We cannot use the console because we would need to do it for each customer and it is complicated.
We would like to use system entities though but I cannot manage to find how to do that in the documentation.
https://cloud.google.com/dialogflow/es/docs/reference/rest/v2/projects.agent.intents?hl=fr#Intent.TrainingPhrase
Thanks for the help !

As Per your Requirement, you want to add system entities to your Training Phrases through the DialogFlow API and export it to the DialogFlow console. You can achieve this by following the below steps-
1-You have to create an Intent Json file where you need to Provide your Intent and in Training Phrases you will Provide your Training Phrase texts.
For example - if your training phrase is “I speak french and my Address is CDA,sec-9”, you have to break the sentence into parts as DialogFlow API does not automatically annotate training Phrases as Dialogflow Console does.
Do not forget to add Whitespaces after each Text Part.
{
"displayName": "details",
"priority": 500000,
"webhookState": "WEBHOOK_STATE_UNSPECIFIED",
"trainingPhrases": [
{
"name":"",
"type": "EXAMPLE",
"parts": [
{
"text": "I speak "
},
{
"text": "French",
"entityType":"#sys.language",
"alias": "language",
"userDefined": "True"
},
{
"text" : " and My address is "
},
{
"text" : "CDA,SEc-10",
"entityType":"#sys.location",
"alias": "address",
"userDefined": "True"
}
]
}
],
"action": "details",
"messages": [
{
"text": {
"text": [
"Here are my details"
]
}
}
]
}
You can add those system entities which are extendable only as per the doc.
After creating the Json file Use the below Command to export intent with training Phrases to DialogFlow console via DialogFlow API.
Note: You need to add your project id in <project-id> field.
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
-d #intent.json \
https://dialogflow.googleapis.com/v2/projects/<project-id>/agent/intents?key=[YOUR_API_KEY]

Related

How to trigger action from Chip Suggestions in Dialog Flow?

I want to create a ChatBot where the user (mostly) selects from Chip Suggestions.
I can't understand how to construct the Chip Suggestions in Flask.
The following yields null:
#app.route('/webhook', methods=['POST'])
def webhook():
two_chips = jsonify(fulfillment_text="This message is from Dialogflow's testing!",
fulfillment_messages=[
{
"payload": {
"richContent": [
[
{
"type": "chips",
"options": [
{
"text": "HIV Testing Schedule",
"link": "https://example.com" #Links work, but I don't want links
},
{
"link": "https://example.com",
"text": "PreP"
}
]
}
]
]
}
}])
return two_chips
Ideally, the button clicking would trigger a new action/intent and the bot would respond with more specific text. I.e. what should I replace the link field with?
This link suggests that there is a replyMetadata field, but that seems to be specific to kommunicate, not Google?
I looked flask-dialogflow, but the documentation is too sparse and conflicting for me.
Those chips which require a link, should be replaced by a list 1. List items are clickable and trigger an intent via events 2 (to make the bot respond with more specific text).
To get started, update your code to use lists and then add the event name you'd like to trigger in your code. Then add that same event name to the Events section of the intent you want to trigger.
Here is an example of what that can look like. I tested a list and clicked on a list item to triggered a test event that ran my test intent:
Are you looking for suggestion chips like the one below?
The sample payload that you have shared is from Kommunicate [Disclaimer: I am founder #kommunicate] and it is specific to Kommunicate platform for link buttons. Seems like what you are looking for is direct buttons/suggestion chips, here is the right doc from Kommunicate for this: https://docs.kommunicate.io/docs/message-types#suggested-replies
As Kommunicate supports omnichannel and multiple platforms web, android, iOS, whatsapp, LINE, facebook, etc so Kommunicate supports its own rich message payload along with Dialogflow specific payload.
For Dialogflow specific suggestion chips, use:
{
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "These are suggestion chips."
}
},
{
"simpleResponse": {
"textToSpeech": "Which type of response would you like to see next?"
}
}
],
"suggestions": [
{
"title": "Suggestion 1"
},
{
"title": "Suggestion 2"
},
{
"title": "Suggestion 3"
}
],
"linkOutSuggestion": {
"destinationName": "Suggestion Link",
"url": "https://assistant.google.com/"
}
}
}
}
}
Source: https://developers.google.com/assistant/conversational/df-asdk/rich-responses#df-json-suggestion-chips

Unable to get the rich buttons to work on dialogflow. It returns Empty Response

So I have been trying to start off with creating chatbots on dialogflow. The issue I am running into is that my chatbot is meant to give users a bunch of options to select from and to take the conversation further from there. In order to implement that, I've used a suggestion chip I've included the JSON file that I am using. However, when testing, the bot detects the right intent but returns an empty response. I've included the code in case that helps.
{
"richContent": [
[
{
"options": [
{
"text": "Chip 1",
"image": {
"src": {
"rawUrl": "https://example.com/images/logo.png"
}
},
"link": "https://example.com"
},
{
"link": "https://example.com",
"text": "Chip 2",
"image": {
"src": {
"rawUrl": "https://example.com/images/logo.png"
}
}
}
],
"type": "chips"
}
]
]
}
If you are testing it in the console, you definitely won't get any response, since there is some issue with the way console works. Use dialogflow messenger to test it. Anyways in the actual production you won't be using simulator to test it. Dialogflow console is a simulator which has some capability restrictions but it will work when you use the messenger.

I would like to add one more conversation to actions.json

I have an application within watson assistant that consumes many services from other endpoints. and I would like to call this conversation (from watson) within a google assistant conversation in a certain intention. for example i will develop a rich conversation on google assistant and in one of the options i will call watson's conversation.
I tried as follows, but it didn't work. does anyone know any example that can help me?
{"locale": "pt-BR",
"actions": [
{
"description": "Launch intent",
"name": "MAIN",
"fulfillment": {
"conversationName": "mainConversation"
},
"intent": {
"name": "actions.intent.MAIN"
}
},
{
"description": "Direct access",
"name": "BUY",
"fulfillment": {
"conversationName": "ExampleAction"
},
"intent": {
"name": "com.example.ExampleAction.BUY",
"trigger": {
"queryPatterns": [
"teste",
"azul",
"start"
]
}
}
}
],
"conversations": {
"mainConversation": {
"name": "mainConversation",
"url": "https://us-central1-ericanovo-798cc.cloudfunctions.net/webhook",
"fulfillmentApiVersion": 2
},
"BUY": {
"name": "ExampleAction",
"url": "https://orquestrador-sulamerica-teste.mybluemix.net/api/v1/chat/google?externaltoken=574213c0-e904-11e9-9970-ff484aa25334",
"fulfillmentApiVersion": 2
}
}
}
thanks
That won't work because the webhook for everything published under the same project has to be the same URL. You are expected to handle all the Intents and "actions" at that webhook.
In your case, you would also need to make sure the request is formatted the way the Watson API would be expecting it. The Assistant will send it using the Conversation Webhook Format, and it sounds like you would send it using Watson's Analyze Text API.
You're not showing any of your code, so it is difficult to be sure - but the first would be in a JSON format that you can extract. You can then use a library in Node (such as request-promise to make the calls to Watson. Based on the result from Watson, you'd need to format the results as a response and return it to the Assistant.
It isn't clear why you'd need multiple webhooks specifically, although it is certainly possible that some Intents may make different API calls than others.
Keep in mind that your custom Intents will only be valid on invocation. Subsequent Intents will all be TEXT Intents.

How to use Dialogflow outside of the Web Console

Is it possible to create a Dialogflow Agent outside of the Dialogflow Web Console?
Is there maybe some Web API I can call that can create an 'Intent'?
And then maybe some other API that can add an 'Event' to that 'Intent'?
And then maybe more API's to add in a 'Training phrase' / 'Action' or 'Parameter'?
I've seen; I can click on the 'Settings' button for my 'Agent' then there is a tab: "Export and Import" and under that tab are buttons: 'Export as ZIP', 'Restore from ZIP' and 'Import from ZIP'.
Can I use those features somehow to write my own ZIP file. Then just import it using: 'Import from ZIP'?
Any help or other suggestions would be appreciated.
You are probably looking for the https://cloud.google.com/dialogflow/docs/manage-intents documentation page, which contains examples in multiple languages.
A sample JSON would look like:
{
"displayName": "ListRooms",
"priority": 500000,
"webhookState": "WEBHOOK_STATE_UNSPECIFIED",
"trainingPhrases": [
{
"type": "EXAMPLE",
"parts": [
{
"text": "What rooms are available at 10am today?"
}
]
}
],
"action": "listRooms",
"messages": [
{
"text": {
"text": [
"Here are the available rooms:"
]
}
}
]
}

How to use dialogflow webhook v2/v1 to response rich messages

Scenario trying to achieve :
When user says "approvals" bot has to talk to api/webhook and response with a list with title and small description
Title 1
abcd
Title 2
efgh
and the user will click select anyone out of it.
Integration type : Website integration
I would like to use nodejs to use as webhook v2 and is there any sample specific to the this .
I saw in v1 webhook there is just a option to send one text as reply . I dont know maybe it supports in v2 can anyone share some sample and information
return res.json({
speech: 'text',
displayText: 'title',
source: 'getevents'
});
You can use Quick Replies Message Object in V1.
Just reply the following:
{
'messages': [
{
'type': 2,
'platform': 'line',
'title': 'title',
'replies': [
'select one',
'select one',
]
},
]
}
In Dialogflow webhook it defines the JSON payload format when Google Actions invokes your fulfilment through Dialogflow v2. So dialogflow natively doesn't support list rich responses, one needs to apply the JSON code equipped from google actions
Here is the sample code for the list template
"messages": [
{
"items": [
{
"description": "Item One Description",
"image": {
"url": "http://imageOneUrl.com"
"accessibilityText": "Image description for screen readers"
},
"optionInfo": {
"key": "itemOne",
"synonyms": [
"thing one",
"object one"
]
},
"title": "Item One"
},
{
"description": "Item Two Description",
"image": {
"url": "http://imageTwoUrl.com"
"accessibilityText": "Image description for screen readers"
},
"optionInfo": {
"key": "itemTwo",
"synonyms": [
"thing two",
"object two"
]
},
"title": "Item Two"
}
],
"platform": "google",
"title": "Title",
"type": "list_card"
}
]
You can find out more from this source link ,
And a tutorial on how to implement this using fulfilment webhook can be found here
But if you want to avoid this hassle, you can integrate dialogflow with some third-party application such as Kommunicate to build every rich message. Where they have the means to implement rich messages using custom payload Dialogflow and Google Assistant and Kommunicate supports all types of rich messages like buttons, links, images to card carousel etc and provide sample codes for the same. For more detailed information you check this article
Disclaimer: I work for Kommunicate

Resources