Any ideas/ examples on how to use the detect-intent api on dialogflow to read the intent from a json file? - node.js

Any idea or examples as to how to detect intent using the Dialogflow detect-intent api(https://cloud.google.com/dialogflow/docs/reference/rest/v2/projects.agent.sessions/detectIntent) from a JSON file?
Thank you in advance.
The function is supposed to be hosted on Firebase functions and I am using nodejs.
I will try to explain what I am trying to do.
So I have a bunch of Intents on Dialogflow already. And I know that the starting intent is going to be the Welcome intent. After the Welcome Intent I want to shape the conversation according to the intent list on the json file.
The entire flow is something like this.
Bot: Hello, What form would you like to fill up today?
User: Leave form
Dialogflow matches the leave form with the leave form entity and pulls the leave form json from the storage. The json will contain the fields that are required to be filled up for the form
Bot: Hi, so I would need some details to fill this form.
Bot: Let's start with your name ..... etc etc
So, instead of detecting the intent from the user's side, I need to detect what intent, from the json. The Webhook fulfillment is currently being hosted on Firebase functions and the json is being stored on Firebase Storage(not Database)

The Detect Intent API only helps you to detect the intent from the text sent by you to the Dialogflow agent using the API. So you cannot read the intent from the JSON file using the Detect Intent API, your intent must be imported to the Dialogflow agent.

Related

How can I trigger intent user free input

I have a bot that should collect feedback.
For example:
Bot: Leave your feedback
User: Everything is great!
My idea was to use a fallback intent for this. But the problem is that the bot has many other intents that can react to this input.
For example, if a user writes the word - email to a user in feedback, another intent is triggered.
How can you implement the preservation of the input in this case?
Create an intent to collect this free form feedback. You will need to trigger this intent with an event or based on earlier user input with training phrases like "I want to tell you something" or "provide feedback", etc.
Once they are in this intent, you can use a parameter with #sys.any as the entity in a parameter to collect that feedback.
Here is what that looks like:
In that example there is a default response configured and you could customize the response or even enable fulfillment to send the input to a Cloud Function or webhook for processing, etc.

Default Parameters in Dialogflow

I would like to make my Dialogflow country-specific such that when my chatbot starts, I like to pass it some parameters eg country and then to insert the country parameter into the intent which is passed onto my backend. Is that possible? I can't seem to find any information regarding that in the docs or maybe, I might have missed out
Thanks in advance
If your integration is via the Dialogflow APIs or using the Dialogflow Client Library, then you can pass the country in the session ID, and then extract the country from the session ID in fulfillment using agent.session.

Triggering next intent without user input in Dialogflow

I'm building my first chatbot using Dialogflow. During my chat sessions, I would like to move on from one intent to another, without having user input in between. This can be seen in this image on Imgur.
The layout of the chat so far can be seen here.
I'm supposed to move from showing the video or article directly to "allright has your car..." without any user input, but I don't seem to be able to. How do I solve this?
I've tried using in and output contexts, but that didn't seem to work.
Thanks in advance!
Events can be triggered through Dialogflow fulfillment or the
detect intent API. These events can be handled in your Dialogflow agent or in fulfillment.
Check documentation here: Dialogflow Events
This means you will need to programmatically do this

Images can be received as input in Dialogflow Chatbot?

i have a Use Case where i need to receive image as input from user in dialogflow chatbot. This images is require to send in webhook request to rest end point as fulfillment.
I couldn't find anything which resembles to my requirement and also not sure whether it is supported in dialogflow or not.
Thanks in advance!
Dialogflow cannot take an image as input and map it to an intent directly. However, what you can do is process that image and send some text to dialogflow which will trigger specific intent and then proceed to perform the desired action.
You need to have a bridge between your user agent and Dialogflow, which will handle all the text/image request. It will do all the pre-processing and then call Dialogflow.
In this way, you need to send message to the messenger user using it's API's and call dialogflow using API/SDK as well.
Hope it helps.

How to get dynamic response based on the result of the action performed in Api.ai?

I'm trying out few examples in Api.ai console. I see there are examples where the agent responds by using the values that are extracted from the user query or from the context. But is there a way to display response that is formed using the output of the action performed?
For example -
User: Is my pizza order confirmed?
Action: check order status
Response: Yes, it's confirmed (or "No, it's not")
You will have to use some custom webhook to do this, either integrating with a 3rd party API or will a server side call of your own to a database- in this case the webhook would take the user's ID and query if their pizza is ready or not, and this would then be passed back to API.ai.
Here is an example using a 3rd party webhook to do what you are asking:
https://github.com/api-ai/apiai-weather-webhook-sample
Yes you can do this with webhooks.
Typically, you would save the status of the order in your db, then you could have an intent that would:
Understand the query of your user (Is my pizza order confirmed)
The intent would call your webhook
the webhook would return the status order.
Api.ai would then give the answer.
When you use webhooks you need to return the speech response, the displayText, optionally the data that your apps need, the contextOut and the source.
I guess you would also need to have implement some context in api.ai so that you could now who is asking about the satus of the order. You would then be able to use the sessionId
Matt is correct here. You must use a webhook. Unfortunately the documentation from API.AI is currently very poor. Here's a screenshot example of an incoming post request. My message function will return an object with a desired response. In this case, I am using a Telegram chat bot. If you are not using any messenger, you can drop the data key: value. FollowupEvent is also optional.
Node.JS code with Restify
On your API.AI intent, make sure to check off Webhook. If you end getting the text response 'Broken' here, then something went wrong and you should check your error codes.
API.AI intent
And lastly, under the fulfillment tab, make sure to enable the webhook and point it at the right endpoint.

Resources