How to notice that a message sent to dialogflow is longer than 256 characters? - dialogflow-es

I made a facebook chatbot with dialogflow. My problem is that some users write messages to my bot that are longer than 256 characters.
Dialogflow just throws an error that the character size exceeded. As the result, the user has no answer.
I don't expect dialogflow to process the input. I just want to get this information in my backend, so I can send the user to the live chat.
Please, say me it is possible (and how ;) ).

By following this you will be able to set the custom webhook => Webhook setup
Make this server live with Ngrok with temporary later on you can migrate to your server
Now you will get event in which you will find your message sent from facebook messenger.
you can write simple JS function to send only 256 character to Dialogflow Functions
str.substring(0,255)
and send it to detectIntent in dialogflow function.

Related

How to use the Discord JS Client without logging in?

I have a service that listens for certain updates and then uses a Discord Bot to post a message on a channel. A random example: every time a team scores a goal, post a message in a channel. I got an email from Discord to reset my bot token because there were too many logins.
As you know, in order to use the Bot you use the client.login("XXX") method. So every time there is an update my service initializes the bot and then sends a message. My assumption is that it has to do with me calling client.login("XXX") for every update. Since my service runs serverless, I can not keep the service up.
Is there a way to make the bot post a message without having to use client.login("XXX")? Or can anyone suggest any strategy to make this logic work?
That is not possible as a bot cannot do any actions without being logged in, it sounds like channel webhooks would fit your needs better.
You simply generate a webhook link in a channel which you can then post messages to through a post request.
You can read more about webhooks here
And you can read more about the required paramters and how to format a POST request to the webhook here

Act on non-text telegram messages in Google Dialogflow. Fallback intent should forward everything

I'm building a chatbot with Telegram and Google Dialogflow. When I integrate Dialogflow into Telegram via the Dialogflow "Integrations" tab, Dialogflow registers as a Webbhook service to intercept all received Telegram messages. Unfortunately, I cannot act on non-text messages like stickers, images and Telegram payment checkout messages.
I wish Dialogflow would forward all the received messages to my custom fulfillment webhook in the Fallback intent. In my webhook, I would be able to parse the received body and act on the unsupported telegram messages accordingly.
I know that there is a FACEBOOK_MEDIA event in Dialogflow. This event is fired when an image is sent via a Facebook messenger to Dialogflow. Is there something like a TELEGRAM_MEDIA or even a TELEGRAM_UNSUPPORTED event available?
I would really like to be able to act on more than just text messages in Dialogflow.
Do I need to add another layer between Telegram and Dialogflow to be able to act on all Telegram messages?
What I have analyzed so far:
I forward all Google Dialogflow interaction logs to Google Cloud stackdriver. It seems as if non-text messages are completely ignored by Dialogflow. I see no log entry at all when I send a non-text message to my telegram bot. On the other hand, when I send a text, the log and its JSON payload appears immediately in the stackdriver.
I created a fallback intent in Dialogflow and enabled "Enable webhook call for this intent" in the Fulfillment section. Unfortunately, my fulfillment function doesn't fire on any non-text events. Dialogflow blocks it in the first place.
For future reference, I will try to give a possible, but not an out-of-the-box solution to my own question. If someone has a better solution, this would be great.
It seems to me, that at the moment of writing this, a full interaction experience is only possible by implementing an intermediate layer between Telegram and Dialogflow. Telegram might contact this intermediate layer, which processes the received message and uses the Dialogflow SDK/API for the Google NLP goodness. For the (not yet) supported Telegram messages this intermediate layer must implement its own logic.
Currently, there seems to be no way to handle non-telegram text messages via dialogflow, however there is an open report about it here if it may interest https://issuetracker.google.com/issues/157202508

i cant visit the message that i sent with getupdates in telegram bot

I can't visit the message that I sent with getupdates in telegram bot
https://api.telegram.org/bot............./getupdates
how can I visit the messages that I sent with my telegram bot?
I want to show the messages that send with a bot with sendmessage method but I couldn't find it
I can find my the message_id between sent messages but I can't visit the message that bot sent
From your question I couldn't extract in which language you are coding your telegram bot.
In node.js for example, using this package, every message you sent is automatically written to the console. If you only want to review your message that should already do the trick. If you need to store it permanently you'd need to either try to find where the console.log happens and apply your own code or save the console output to a file (like mentioned here). Later on you could for example apply a regex to filter the needed messages.
Note: If you are not using any programming language yet (and are just sending to the telegram API URLs) you have no easy possibility of reviewing your sent messages apart from intercepting the HTTP packets.

Facebook Messenger Chatbot messages tagging (of sorts)

I have a Facebook Messenger bot (written in NodeJS) and a separate control panel where a user can manage the information that the bot is working with (like inventory stock, etc.). One of those things is a log of all conversations between the bot and a visitor. The control panel allows the admin users to send messages to visitors through the bot. There is an input box where they can type in a message and when they click 'Send', the message goes to the bot app, which then sends it back to the user through Send API.
Messages are logged into a database; those going to the bot (from the visitor) are logged when they're received, and those the bot responds with are logged through the 'echo' callback.
The problem with this is that the bot can reply to certain visitor commands (phrases) and tries to perform certain actions based on the input. I'm using Wit.ai for this, but due to the scope of the possible phrases and keywords, the default mode when someone sends a text message is to send it to Wit.ai for processing. However, if an admin user sends the visitor a message from the control panel, the visitor could want to respond to that message (instead of sending a bot command) and that response should not go to the Wit.ai for processing. And due to the sheer scope of possible variations of what can be said, coupled with the fact that they can actually use some of the keywords in the response as well, processing the intent with Wit.ai in that case is too uncertain.
I was wondering if there's a way to somehow identify/mark the source of the messages that the bot sends to the visitor, so when an echo callback comes, I can know if it's, say, from a regular bot routine or from a user-entered reply. Like some additional meta tags that could be sent with the message that would also get returned with the echo, but that doesn't pollute the message itself. Is something like that possible? Or is there a different way I can achieve the same result.
I don't wether that helps you, but Facebook just recently integrated a quite mysterious Tag feature for bots.
https://developers.facebook.com/docs/messenger-platform/send-api-reference/tags

How does Facebook Messenger connect with Wit.ai Bot Engine?

In Facebook's documentation they refer to wit.ai Bot Engine, but I can't find anywhere online where its explained how to connect the Story that you build in Wit with your Facebook Messenger App?
Wit.ai needs an input - user input. Sentence, phrase, word - to give you back the analysed results.
So first when you say "your Facebook Messenger app" - you need to make sure you are handling the messenger part by itself: have a code in your language of preference running on the server\your laptop which can receive the text which is sent to the messenger account on Facebook.
When you get that working, you will have to use one of Wit.ai libraries for the code language you are using to pass that phrase you receive from the user chatting through the messenger to Wit.ai "library" which will communicate it "to the wit.ai stories" you have and get the result from them.
For example for Python:
Library to handle FB Messenger chatting
Wit.ai library to pass the user input "to stories and get result"
You can integrate Wit to any messaging API. Using the Messenger Send/Receive API for example, you will be able to get and receive messages from/to Messenger users. Wit.ai can then parse the messages and predict the next response.
Here is an example in Node js: https://github.com/wit-ai/node-wit/blob/master/examples/messenger.js
I reviewed the latest updates on wit.ai. It seems that Wit.ai does not have an in-built integration with Facebook Messenger. That is, you can't plug it into Facebook Messenger directly by using the page access tokens etc.
What you'll need to do instead is set up a webhook where Messenger will send callbacks with the details of the user's message. If you want you can enable Facebook's in-built NLP too.
Then inside your webhook, send a call to Wit.ai, and get its output in JSON. Then you must process the JSON and send a reply back to the customer using a Sendmessage API call.
It's a bit long-winded, but if you have this setup, you can potentially use any AI engine in the backend. Including wit.ai or dialogflow.

Resources