Dialogflow fulfillment return an empty response - dialogflow-es

I'm trying integrate GA with dialogflow. GA events will be triggered using a fulfilment API, and responses will come from the dialogflow. This setup is already working, however i'm getting the error below when i send an empty fulfilment response.
Is it possible to send a request to the fulfilment api and not returning a response? Thanks in advance!
Error: No response has been set. Is this being used in an async call that was not returned as a promise to the intent handler?
at DialogflowConversation.response (/var/task/node_modules/actions-on-google/dist/service/actionssdk/conversation/conversation.js:237:19)
at DialogflowConversation.serialize (/var/task/node_modules/actions-on-google/dist/service/dialogflow/conv.js:160:129)
at Function.<anonymous> (/var/task/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:173:28)
at Generator.next (<anonymous>)
at fulfilled (/var/task/node_modules/actions-on-google/dist/service/dialogflow/dialogflow.js:19:58)

In short - no.
Conversations aren't much of a conversation if one half of the conversation doesn't say anything. At the very least, you should respond to indicate you got whatever the user has said, and best practice indicates that the reply should prompt the user.
While there are some tricks you can do to make it sound like there isn't a response, they should be avoided where possible.

Related

How to make an asynchronous http call from bot-composer?

I'm creating a bot in botcomposer(v1.4.0) which involves an http request. What I'm looking for is an asynchronous call so that I don't have to wait for the response from the http call, while the user can continue to chat with the bot.
Also, I want to prompt the user when the response comes.
Thank you in advance.
Proactive messages would be the best option. Unfortunately, they are not implemented in Composer at this time. You might be able to create a custom action and accomplish your goal (my assumption without knowing more of what your requirements are).

Follow-up no intent is not working and throwing MalformedResponse

I'm trying to create Action on Google using the DialogFlow. And using a concept of follow-up intent.
My Intent structure is given below,
default-fallback
default-welcome
invoice-number
|- invoice-number-no
|- invoice-number-yes
|-part-number
|-part-number-yes
|-part-number-no
I think there is no issue with my code(fulfillment) because,
I'm able to reach till "part-number" now I have two option yes and no.
(invoice-number->invoice-number-yes->part-number)
If say yes, it is working perfectly but when I say no, it is not even
calling webhook, and directly throwing MalformedResponse error.
Error:
MalformedResponse Failed to parse DialogFlow response into AppResponse
because of empty speech response.
I compared intents available in DialogFlow and intent implemented in my webhook, and it seems I implemented all intents. Still, let say I forgot to implement intent then I think, action on google lib will throw no matching intent expectation if it trys to find intent which is not implemented. But there is no such error either.
What can be a solution for this?
Thanks in advance

Dialogflow messenger-referrals

I'm trying to get the GET_STARTED payload with reference parameters firing to my chatbot running on a node express.js instance.
If I do a get started with refereral call with no active conversation thread, I can access the parameters no problem.
The issue is, however, if I click on a referral link with a conversation thread with my bot already open. I get no post to my fulfillment server.
I have enabled messaging_referrals within the facebook developer console, is there some Intent or Event I need to create within the dialogflow console to pass it to my webhook?
For Context:
Messenger ref parameter is not passed to dialogflow
https://productforums.google.com/forum/#!msg/dialogflow/oldK752j-Ok/GrwJajfwBAAJ
https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messaging_referrals#customer-chat
https://developers.facebook.com/docs/messenger-platform/discovery/m-me-links/
In case anyone stumbles upon this in the future, I received a reply from DialogFlow support, stating that they don't support this functionality.

How can I trigger a dialogflow intent inside a javascript code?

I have a chatbot using dialogflow agent. I wrote a javascript back end code for its webhook fulfillment. I checked some condition in this code and if the condition is true I want a special intent to be triggered. How can I do this? What is the correct java script code to triggered an intent inside a java script if statement?
What function do you intend to perform by triggering an intent? Diaglogflow has v1 & v2 API references for this. You can do GET/POST/PUT/DELETE operations by triggering an intent using ajax call in your javascript code. Please read more about this here https://dialogflow.com/docs/reference/agent/intents
To make things clearer, DialogFlow intents are triggered by querying using the query API (https://dialogflow.com/docs/reference/agent/query)
Note: V1 of the DialogFlow API will deprecate soon, and will be replaced by V2 which is using gRPC.
This means that if you wish to trigger the intent programmatically and have the fulfilment triggered as well, you should have the following:
Script (can be on JavaScript as you would like to) with REST API request (doable using the Axios library) to the DialogFlow Query API.
DialogFlow will pick up the query, runs it through and triggers the Intent (if the query matches the intent).
In processing the intent, because there is a fulfilment, DialogFlow will run the fulfilment, which is another API/webhook call to your server hosted somewhere.
Your server will pick up the API request, and process accordingly.
Try out the Query API from DialogFlow and see if it works out for you.
Okay, I am late here, but I have used the below approach to encounter such a situation.
You can use custom event and intent chaining.
I followed the below URL and implemented the same. Maybe this help someone.
enter link description here

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