Facebook Messenger Chatbot messages tagging (of sorts) - bots

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

Related

Sending a message to user when user enters a geofence / area?

I'm making a dialogflow agent that will be integrated with various platforms (Facebook messenger, slack and maybe a few others) that will have the basic functions of a informational chatbot.
The agent will be for a specific store and I'm wondering if it's possible to trigger some sort of welcome message once the user enters the geofence (in this case, the store)?
Thanks for the help. I haven't found any documentation for this on dialogflow specifically or anywhere else so anything will be awesome.
Note: I'm am not by any means dead set of dialogflow, if AWS Lex offers something like this and it's better, I will take a look. I'm just a bit more used to dialogflow.
This cannot be achieved just by using either Lex or Dialogflow. Because at the end of the day, you are using them to integrate with Messenger/Slack/Whatsapp and these apps will (for obvious good reasons) not share the user's location information with the bot. You will need a helper app which takes the user's location permission as well and triggers the bots for you.
Keep in mind that channels like Messenger and Whatsapp have restrictions over sending messages willy-nilly to users. Messenger has a '24+1' policy Whatsapp also you can only send free form messages in the 24 hour window. But after that you can send chargeable pre-approved "hsm" message templates.

Send private message to a slackbot without other users of the workspace seeing it

How can i send a private message to a bot other without users seeing it on the channel?
Im using node js and the module slackbots. And each time i communicate with the bot it goes something like this: "#robot hello" but everybody on the chat sees it.
Your example is not a direct message, but a so called "mention" in a channel, which is always visible by everyone else in the same channel.
But you can also send a real direct message to a bot user. It works the same like sending a direct message to any user. e.g. click on the plus next to "Direct Messages", select the bot user from the list and click on go. Now you got a direct messaging channel with that user which is 100% private.
Your bot obviously needs to be ready to receive messages via DM in order to respond correctly. e.g if your are using Slack's Events API you need to subscribe to message.im to receive posts in the direct message channel to your bot.
Check out this help desk page on how to send direct messages.
Another approach to communicate "secretly" with your bot user in a channel is slash commands, e.g. by posting /mybot hi in a channel. Both the slash command and respond from your app will not be visible to anyone else in the channel (that is default - but can be changed).

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.

How to use trigger event in facebook messenger bot

I'm developing Facebook messenger bot. Based on the official sample
here made by Node.js, Express, ES7.
I want to use Firebase database, trigger event.
If someone updates the database, send notice to certain people. I add source code "Child Changed" to "messages.js" in messenger-api-helpers, but it doesn't work.
I can check working "Child Changed" in HTML, but in messenger, I cannot.
Where should I write the trigger events code?
You should definitely use Facebook Messenger Broadcast API for this kind of functionality. This will broadcast a notice/broadcast to users.
Caveats:
You have to apply for this permission. (pages_messaging and pages_messaging_subscriptions.Takes about 1-2 days, but
can test on Admin/Test users of the app)
Each broadcast has to be a separate broadcast. (e.g. you can't send image and a text together, each has to be its own individual broadcast).
Have some kind of un-subscription option as well. FB user might think you are spamming even if you clearly say in the messages that your bot will send updates.
Use custom labels to create targetted sends. So you can either subdivide who you will send updates to about specific issues or just label people if they unsubscribe to your broadcast or not.
Basic workflow:
Get permission to broadcast.
On event in your Database. Start process.
Create message_creative_id via POST to endpoint
Use message_creative_id to POST a broadcast_messages
On a successful send you will get back broadcast_id

API.AI A bot that starts the conversation

I am just now creating my first bot for my own use, and I want
to gather user information and search through my database for it.
I figured the best way for this is just to ask the question before the user
starts the conversation. Does anyone know how I can accomplish this (getting the bot to send a message first)?
Trigger an event as soon as user comes to the chat bot platform - see https://api.ai/docs/events. Nearly all platforms triggers an event for users first time. Check the facebook bot docs.
There is provision to do so in api.ai. The event is a feature that allows you to invoke intents by an event name instead of a user query. You just need to define event names for intents. Then, you can trigger these intents by sending a /query request containing an event parameter.

Resources