Send unanswered questions to email in Dialogflow - dialogflow-es

I'm trying to configure dialogflow to handle unanswered question. What I'd like is...
User asks a question
Intent not found
Default Fallback says 'sorry, can I get your email'
User provides email
Webhook sends an email to an admin inbox with the original question in it so somebody can pick it up and reply when they can.
So I can get most of this working except making sure the NodeJS webhook has the original question, as the actual intent that's triggering it is 'provide an email', not the original failed question.
Any advice very welcome...

Probably the easiest approach would be to take advantage of Contexts. This saves a database operation until you have all the information you need from the user, and helps make sure you are collecting the email address at an appropriate time.
Under this scheme:
A Fallback Intent triggers the webhook, which
Responds asking for the email address
Includes a Context as part of the response with the question in a parameter
You would then have another Intent which has this Context set as the Input Context. When this Intent is triggered
Send the request to the inbox, save the info in a database, whatever.
Reply to the user and clear the Context.
You may have other Intents, or a Fallback Intent, which has this Context as the Input Context as well. These may provide replies saying you need an email address to forward the question, or cautioning them that if they don't provide it, you won't be able to get them an answer. This handles the case if they don't wish to provide an address, have changed their mind, etc.

Possible answer...
Default fallback triggers the webhook, providing question and sessionID which is then stored in a database
Fallback asks for email address
Provides_email intent triggers webhook again, which then updates the original record to include the email address, and sends the request to the inbox.

Related

How to ask "Was this helpful?" in DialogFlow at the end of conversation after rendering the response from Intent

So I have a flow prepared.
User: I would like to book an appointment
Bot: Sure. Does 3pm works for you?
User: Yes
Bot: Great. Appointment has been set. (Response from Fulfillment)
Bot: Anything else you need help with? Yes | No (How to achieve this)
I have tried triggering followupEvent but that won't display any response till the chain of intent is complete.
When the followupEventInput parameter is set for a WebhookResponse,
Dialogflow ignores the fulfillmentText, fulfillmentMessages, and
payload fields. When Dialogflow receives a webhook response that
includes an event, it immediately triggers the corresponding intent in
which it was defined.
I have End Intents ready for response for Yes and No. But need help in triggering it.
An intent shouldn't be used as a step in your flow or be tied to a single response, its intended to represent a category of phrases your user might say to complete a certain goal in your conversation. Since the was this helpful isn't triggered by any user phrase, but more as a trigger for the user to continue the conversation shows that it shouldn't be a separate intent.
Having the was this helpful phrase be available to multiple intents is a good choice so it can be used throughout your conversation, but I would recommend saving this phrase in a file, an API or a CMS and retrieving the response via code.
I'm not a PHP developer, but I expect it to be along the lines of: responseService.getResponse("requestFeedbackPrompt");
This allows you to retrieve the was this helpful phrase throughout your code, without making the mistake of making a seperate intent for it, as this will create problems later on with keeping state.
If you would decide to go with a single intent for this, you will quickly see that it will become difficult to maintain track of context, states and which step of the conversation you are in as multiple intents will go through this generic intent.
What would you do if you need a different variant of the was this helpful response, with the single intent, you will end up creating an intent for each variation and you will have to align the conversation flow and state accordingly every time.
If you use the service, you just call responseService.getResponse("OtherFeedbackPrompt);`
Hi have something similar in one of my bots. I have taken a different approach to those mentioned.
My bot asks if there's anything it can help with at the end of a an acknowledgement fulfilment.
The customer then has the option to respond with Yes or No.
Within the page that asks the question I have created routes.
One route for Yes and another for No.
The Yes route directs customers back to the point where they can start making selections. The No route provides a fulfilment to the customer and ends the session. I have used Yes and No intents for these.

Trying to create a follow-up intent to capture contact information

I want to create an intent for personal follow-up with anonymous visitors. I have created a "getfollowup" intent that triggers when visitor asks for escalation, speak to a manager, etc. I want to create yes/no follow-up intents and trigger a "getcontact" intent for "yes" answer. The getcontact intent is created to capture #sys.given-name and #sys.email for slot filling. I'm having trouble getting the two intents to connect. Here's an example of how I'd like the conversation to flow:
...
Visitor: I need to speak to a manager
[getfollowup intent triggered]
Response: Sorry I haven't been able to help. Would you like me to have someone reach out to you?
Visitor: Yes
[getfollowup-yes context]
[need to trigger getcontact intent here...it is this transition that I can't figure out]
Response: Ok. First may have your name?
Visitor: John
Response: Thanks, John. May I have your email address?
Vistor: john#example.com
Response: Thanks for the info. Someone will reach out to you shortly.
In general, you don't "trigger" an Intent. Intents capture what the user says, and not what you do with that.
So the approach in your case would that when the user says "yes", you simply prompt them for the information you want and set a Context indicating you want this information.
You can then create other Intents (such as your "getcontact" Intent) that take this as an Input Context and have the user providing the information you've prompted for.

How to make the chatbot redirect a unknown answer to my email so I can manually answer the problem?

I’m new to Dialogflow and I want to make a chatbot for faq and troubleshooting. I want the chatbot to send me responses that I do not know how to answer so I can manually contact the people whose problems have not been solved. How do I achieve this automatically?
I am assuming you will have different intents for your FAQ system, so that if user asks a question it will be matched to specific intent and bot will send a response according to that matched intent.
Now if none of the intents matched, it will go to Default Fallback Intent where you ca enable the webhook. In the webhook, you can write a function to send email yourself with the user query and other user details so that you can check and reply to the user.
As previously mentioned, you could have your endpoint recognise that the fallback intent has been triggered, but you will also need to obtain the users email which is outlined here Get email from user using Google actions , otherwise you wont be able to get back to the user with a response.

How to send a response to dialogflow later

I am using dialogflow by google to create a bot.
When my user ask my bot for a report with several parameters, I need to create the report and send him the link to download it.
The report is created in about 1 minute. When I send the response (JSON(fulfillmentText = "my url")) of the POST request of my webhook, dialogflow send me an error : time out.
So I need to send immediately the message "Please wait..." and then, when the report is created, send to my user a new message with the url of my report.
I am trying to use the API V2 but I cannot find in the documentation a way to send a message to a user when the POST request is already done.
This is not possible, the interactions with Dialogflow agents are intended to be conversational and must be initiated by the user. The timeout for your fulfillments response is five seconds.
It would probably be a better user experience anyway if you get an email address from the user and send them the link there, either by asking for it with the #sys.email system entity (be aware of privacy issues though) or by using account linking.

Server-side query using events or/and context?

I’m coding a bot using PHP-BotMan for complexity reasons and using Dialogflow query api to extract and manipulate the informations from the response. I saw examples and hints from people here and on dialogflow forum suggesting using context or events, some of them mixing both. What is the better way to handle this?
The flow of the application is:
user messages bot
bot queries (text or/and #event?) dialogflow
internally process a reply or return dialogflow slotfilling* request
text response bot reply user with last reply or asking to fill slot
Also, how can I be sure that a slotfilling process is finished with “actionIncomplete” only having two values, NULL or TRUE? The dialogflow query response doesn’t show wich slotfilling parameters are required or not…
Thanks for the help!!
slotfilling is when dialogflow sends a text response requesting required parameters to finish an intent, adding those replied values to the context
I was trying something similar to your scenario, here are few points i found helpful:
When Slotfitting with webhook, i can't use the "Required" params field since i have to control the input parameters via webhook (query database to provide options). Which means actionIncomplete field is not useful anymore.
I personally prefer to use context as it can add/remove params which gives you more control.
Hence the dialog was designed to use webhook to check all required params before move on to next conversation flow. and pop quick replies menu to ease and restrict possible input from users.
HTH.

Resources