Get your DialogFlow agent to initiate the conversation before user types a message
First published: Aug 2017 | Last Updated: May 2022
So let us understand the question:
When you work with Dialogflow you notice that it follows the “user types something -> agent replies with an answer” sequence. Suppose you wish to get the agent to say something before the user types anything, how do you do it?
Example
In my CourseBot (seen above), I initiate the conversation by using the same ideas described on this page.
Dialogflow Built In Welcome Events
When you click inside the Event textbox in Dialogflow, you will notice in the autocomplete a bunch of CHANNEL_WELCOME eventsEvents are used in both Dialogflow ES and Dialogflow CX as t... More.
What are these welcome events?
In principle, this is the feature you should use to initiate conversations on different channels.
Take a look at this page in the documentation, for example:
The reason I say “in principle”, is because I haven’t been able to successfully implement the bot automatically sending a message at the start of the conversation for some of the channels.
Here is a little report card.
Note: This is my old website and is in maintenance mode. I am publishing new articles only on my new website.
If you are not sure where to start on my new website, I recommend the following article:
Is Dialogflow still relevant in the era of Large Language Models?
Hi,
I have a question pls, How can I send a value from another app to my dialogflow agent. it’s urgent, Please.
Dialogflow does not support out of band push notifications like what you are trying to do. The agent has to initiate the communication if it wants to receive a response.
Hey,
I have integerated dailogflow with servicenow. and I have made a voice assistant android app which is connected to dailogflow. Can you tell me how can i do user authentication. (I don’t want to do it with gmail. I want to do it with servicenow username & pass). Thanks in Advance
Sorry, I haven’t used ServiceNow till now.
Do you know how to send session_id / user_id while requesting/querying to dailogflow
I don’t have any material on this at the moment, but I will probably be creating a mini-course on it soon.
I am able to test Facebook welcome event. I have created separate intent by name Welcome_Event and added ‘Facebook Welcome’ event and added text response for ‘Facebook Messenger’ channel. Now if i click on ‘Get Started’ button in Facebook messenger I can see the ‘Welcome_Event’ intent getting fired and correct welcome message!
Thanks for the update, Satish!
how we send response to user after 20 seconds?
You need to use a custom integration.
Can DialogFlow initiate a message to any user (in particular, in telegrams) on some Action (for example, send a reminder by time)? In the documentation, it seems to be described as https://dialogflow.com/docs/events/custom-events. I tried using different (via POST request or WebHook) methods, but I only get the response to ACTION in the response to the request: detectIntent, although I specify same session on which the telegram user is connected. But the user does not receive anything in the telegrams on the event, no message. Why?
You need to use a custom integration.
Hi Arvind,
How can i send value in fulfilment and use globally for all function in fulfilment .is there any way to send value in fulfilment when chatbot button is click.Please suggest if any node js example exist please let me know.
You can programmatically add your global value into session-vars and use the value in later steps.
If you need additional help, you can schedule a paid consultation.
Hi Aravind, I need the bot to trigger first without user trigger. Am using dialogflow with Nodejs as backend framework. That too I need as a webchat only. Can you please help me on with any suggestion.
Bot has to trigger like this in nodejs framework.
https://learn.miningbusinessdata.com/p/coursebot
That would be an entire course. If this is very urgent, you can get in touch via my contact form for paid 1-on-1 Skype consultation.
Hi Aravind,
Hope you are doing good.
I’m working on creating a chatbot using Dialogflow and FB messenger integration, wherein I have a requirement to get a picture as response from user and I need to save this picture.
Can you suggest how this can be achieved?
Sorry, I haven’t done this and I don’t do Messenger integrations anymore.
Thanks for your reply 🙂
Hi Arvind,
I want to use integrated web demo iframe. Is there any way, in which i can pass the user name and password silently and authenticate it with the help of webhook and then fetch the profile and fetch the name and it should appeare when looged-in user open the chatpot – “Hi Ankur”
Its not possible.
Can we achieve this using custom dialogflow agent?
Yes, and you can get my course if you are interested in learning the general principles behind this.
The function for Skype was similarly bad ヽ(`Д´ )ノ
Hmm.. that’s too bad. Hope someone comes and updates this comment thread when things start working.
You can get the rest of the information to initiate the facebook event from here, https://developers.facebook.com/docs/messenger-platform/discovery/welcome-screen/
Hi Eduardo,
Thanks for the update.
Hi, Aravind! How are you doing?
I did the steps you taught on here, but I’d like to know how the people can chat with it. Thank you!
Its quite complex, and I will be releasing a course to explain how to do this over the next few weeks. If it is urgent, get in touch with me via my contact form for 1-on-1 Skype coaching.
Hi Arvind need skye coaching for one issue if its possible please let me know.
You can book a Zoom call here if you are interested.
is there any other way to book appointment bcoz of payment with paypal not initiate don’t know why this
I have added an additional payment option (Gumroad).
unfortunately gumroad also not working
I don’t offer any other payment method as of now. My suggestion is that you should find someone else who is able to accept payment from you.
Hi,
I’m using. Python code in my webhook, can you please help me understanding how I can achieve the same with it??
I have answered this here (you cannot do it from your webhook code)
Aravind, this works perfectly for me, but I don’t understand how to use the API response.
Would the response text be displayed somewhere automatically ? How and where are we supposed to print the text in our application (say, Web demo of DialogFlow)
You need to build out your own chat UI for a website chatbot. Dialogflow’s built in web demo integration doesn’t support this. As for other channels like FB and Slack, you will need to do build out a custom integration and also figure out how to use their APIs to push messages into the chat window. You can expect it to be quite a bit of work.
Hi, i try this in postman and i get the json response. But is there a way to see how i get the message from the bot in real time once i call this intent through the event?
It is quite reasonable to assume the response via Postman will be exactly the same that comes back if you were to use it inside your actual app. I would recommend building out the API call in the programming language of your choice, and look at the response object coming back. It will have the intent response (and all the associated info) and you can proceed to your next step.
Hi, Aravind! If I got it right, we have no options how to write to a FB or Telegram user without user’s request. However, it depends on using one-click integration. If I use custom integration with Telegram, FB Messenger – I can use events(as push notifications) only by:
1. Generating and using SessionId.
2. Having SenderId.
How do you think – is it enough?
In theory, that is correct. I know for sure that it works for website chatbots, where I have direct experience. I am not sure if there are many people who have actually accomplished push notifications from Dialogflow to Telegram, FB Messenger etc. Be sure to read this article. Also ask on StackOverflow to verify if your approach will work (although I think you are on the right track). Finally, if you do get it working, please leave a comment below. I think many people might come to you for help at that point. 🙂
Thank you a lot! Also I have one question more. Do you know how long sessionId lives?
I remember running some tests a while back and think it was about 20 minutes. Haven’t tested it recently.
Thank you! When I’ll check “back-channel” events I’ll write here.
Hi Kirill…I am a student in Spain trying to develop a bot using Dialogflow, Firebase and Telegram. I have been trying for a while to get my Telegram bot to initiate a conversation periodically if the user doesn’t do so for a few days, do you know if this is possible? if so, could you please help me? I am desperate
Hi Aravind, How do we get a sessionID without the conversation getting initiated? Thanks in advance
You need to generate your own sessionID, and then (depending on your goal) make sure you use the same sessionID for a given session when interacting with the REST API.
Hello Aravind,
Can you please help me with the otp sending using twilio in dialogflow.ai
Sorry, don’t have any experience with the Twilio integration yet.
Hello, I saw in your previous answer to Jon you highlighted there is no Push Notification concept in Dialogflow. In this case, can you kindly suggest me how I can exploit this feature with a Google Home device?
Thanks in advance for your help.
Raul
The closest to this is the concept of notifications they have recently introduced for Google Assistant apps. I haven’t yet worked with them though.
Hello Aravind, thanks a lot for your prompt response.
I think the new “notifications” feature won’t be usefull for my specifc purpose.
Anyhow my previous question was intended about: how I can exploit the feature related to run an intent by invoking relevant “event” through call REST api (as per your example here above … “https://api.api.ai/v1/query?v=20150910&e=event_name&timezone=Europe/Paris
&lang=en&sessionId=1234567890”) in order to experience the final effect on a “screen-less” device as Google Home speaker ?
Finally,since my agent has been migrated to V2 API, I kindly request you how to submit the equivalent HTTP Rest invokation above with API V2 version (or if it is really needed…)
Thanks again for your patience and I’m sorry for my bad english and for the previous misunderstanding.
Raul
That’s quite a bit complex to answer. You can get in touch for 1-on-1 coaching if interested.
I would also like to know how to adapt this to api v2
Hi, I want to know how to store data in the database through webhooks in node.js
I am thinking of creating a course about this. Will leave an update here when I release the course.
Can I use this method with an already existing chat? Do I need to get the sessionId from that chat? If yes where do I found it?
By already existing chat, do you mean the integrated web demo?
In my case, I mean a telegram chat. I would like to send a message without the user having written a message. Is this possible with an event?
If you build your own custom integration for Telegram instead of using the existing 1-click integration, it is possible. Otherwise it isn’t, to the best of my knowledge.
Ok thank you.
Hi, I want to notify user that ‘user typing…’ before response displays in Dialogflow chatbot. Is it possible to implement using dialogflow event? Or any other way we can do it?
You cannot do it using the built in web demo integration, but you can do it using the custom chatbot system I describe here.
Hey Aravind, how can I store the user replies in the firebase?
I will be creating some learning material about this quite soon.
I have made it WORKING. Kindly check the detailed answer here https://stackoverflow.com/questions/45994460/need-to-get-response-of-user-name-and-email-in-api-ai/49627985#49627985
I don’t think your SO answer is relevant to this particular post, but thanks for the comment. 🙂
Aravind, great! Thanks!
Great article. I’ve been looking for this capability for years! Is there a way you could use IFTTT to trigger the Event? For example if I unlocked my door using a smart lock that could send an IFTTT message could this trigger the event?
One important thing to remember when you do this is that the “response” from Dialogflow (that is, whatever is in the Response field inside the specific intent) will automatically be sent back to the requesting app. That is, there isn’t any concept of “push notifications” in Dialogflow. If you aren’t thinking of push notifications, then it will work OK.
how did you change the UI of the dialog flow chat bot
when am doing it,its showing powered by Dialogflow and am unable to change the UI of the frame
The built-in web demo will not allow you to do this. You need to create your own custom UI and interact with the Dialogflow agent using the REST API. You can use the system described here: https://botflo.com/rich-webchat-dialogflow/
Hi, Aravind is there a way to trigger an intent at a particular time automatically?
In theory, you should be able to set up a scheduled task which runs a script at a particular time. The task will call Dialogflow’s REST API and invoke the corresponding Event using the /query endpoint. Would that work for your use case?