I got this question recently in my comments:
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?
This is a good question, and you need to understand how Dialogflow's 1-click integrations work.
Remember that when using the default 1-click integration, there is already a sequence of things which are going on. Unfortunately, you don't have any way to modify the integration code (as it is hosted and deployed on Dialogflow's servers).
So you need to build a custom integration.
Note: While I have done custom integrations for Telegram bots, I did it a while back so it is possible one or two things below may have changed. But the overall sequence I am describing below is correct.
If you want your Dialogflow bot to send time based reminders to Telegram users you need to
a) build a custom integration (i.e. you should set up a webhook to get a notification when user sends a message to your bot)
b) get the user's chat_id using Telegram's API when user sends a message to your bot (inspect the Message object, which is in JSON format, and get the chat_id field from it)
c) and then use the Telegram API to send a message to the specific chat_id so that it lands inside the chat window of that user.
I would expect a similar sequence to work for other channels too (and let me know in the comments if that is incorrect).
Notice that in the steps I have described, we didn't have to use Dialogflow custom events at all. That is because these custom events only make sense in a "request from user" followed by "response from bot" scenario, in other words the Event itself fires as a response to a previous request. (Don't worry about this if it isn't clear. Just follow the steps I have provided).
Custom vs 1-click integration
In summary this is one more reason why a custom integration is preferable to a 1-click integration when you are building channel integrations with Dialogflow. In fact, I would go as far as to say that if you are going to build a reasonably complex Dialogflow chatbot, you should get familiar with how custom integrations work.
I am creating a course about Dialogflow Custom integrations and hope to publish it within the next month or so. You can get updates (and a discount) when I release the course by signing up for my email list. The simplest way to sign up is to enroll for one of my free courses.
- Client Question: Can I use GPT2 for my Dialogflow bot?
- Weekly Free Mini Courses
- 15 things all Dialogflow bot makers should know
- Autogenerating FAQ bot from training text
- A MUST read article on Dialogflow training phrase quality
- Using Collect.chat for preNLU bots
- Reader Question: How to get some sample training data for Dialogflow?
- Getting the top 3 (or top N) intents in Dialogflow: An experiment
- Dialogflow Regexp (regular expression) entity
- Using Dialogflow for educational bots