How to detect bot message/user message? - node.js

My FB-NodeJS-API prototype is not working correctly because my webhook is receiving the bot respond which is then sent to API.AI.
I need to set a condition where only a user's message should be received on the webhook request or only user's message should be sent to API.AI.
Can anyone advise me on this?

Can you explain the problem better? Please add the relevant code.
The bot response should go the user, not the webhook. The user input will come to the webhook.
I would suggest getting the bot to work without API.AI first and then adding support. My bot is in node.js so you may just want to jump to the source code.
For more information on setting up a bot see my article Facebook Bots for Fun and Profit
The example bot is DMS Software Bot
The source code is Github fb-robot

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

How do i make my Chatbot Message have some seconds of delay response in dialog flow?

I'm creating a chatbot for a Facebook page to solve people's questions and I wanted to make the bot messages 1 or 2 seconds of delay between each of the bot's replies. Could someone tell me how to do it in dialog flow? I couldn't find any answer around my research so hopefully someone could help me.
This isn't possible if you're using Dialogflow's built-in rich messages. It also wouldn't be possible using only webhook fulfillment and the Dialogflow Facebook integration, as you can only deliver a full set of messages as a reply at one time, and can't specify how they are delivered.
The only way to achieve that level of control would be to build the bot yourself (perhaps using an existing Messenger bot framework), and make calls from that code to Dialogflow to handle natural language understanding.

Chat messages from Dialogflow don't appear in Slack

I'm creating a bot with Dialogflow. It's quite straigtforward, and it worked on Telegram in no time. But things complicated when trying to integrate Dialogflow with Slack.
My bot is able to read direct messages from Slack, and I'm sure of it because the messages from Slack appear in the History section of Dialogflow. Good news there. In the same screen, I can see that Dialogflow answered all the messages Slack sent to it. But sadly, those answers don't appear in Slack.
By the way, just to confuse me more, the Dialogflow's test bot works flawlessly with Slack, publishing there with no issue. So, it's not anything related with the common values you have to copy from Slack and paste to Dialogflow to enable the integration.
It seems that my bot on Slack misses some kind of permission of the OAuth & Permissions screen, but I've tried some of theme, and I can't find the good one. Right now I'm using bot, chat:write:bot, im:write, and channels:read. I guess that only the two first ones are needed, but I'm totally lost and tried adding permissions with no reason. And then, I wrote this post.
Is there someone who has a simple bot that sends messages in direct messages on Slack? What are the needed permissions?
I had the same issue, it's quite easy to solve: just go on Manage Distribution in your bot's Slack API panel and click on the "Add to Slack" button.
That's all!
Under OAuth & Permissions, add "chat:write" to OAuth Scope. That will allow your bot to send messages to other users.

How to read a message from a bot via telegram API?

I have a room with a couple of bots, one of them needs to read all the messages on the room including other bot's messages.
Telegram API says bots can't see other bots message otherwise they might get caught in a "loop".
Since i really need to work around this i'm wondering if there is a known workaround?
There cannot be any workaround using the Bot APIs since the messages in getUpdates or webhook of the Bot will be from Users alone.
One workaround could be to use the telegram-cli and create a normal user as a Bot.

Telegram Bot webhook really slow

I've created a telegram bot and set a webhook as described in the docs. For testing purposes I've set it up so once you send the bot a message it replies back with the same message.
Now the issue I am having is that the updates from telegram are coming back really slowly and there are some messages I haven't received yet. Am I missing something or is the webhook method just really slow?
I had the same problem. Turns out I wasn't responding the telegram server after I got the POST request. Due to this, the server wasn't sure if I got the previous updates and was constantly sending my webhook past updates.
I have an express server and I added this bit of line after handling the POST Request.
res.sendStatus(403)
You can also confirm this by going to this url
https://api.telegram.org/<token>/getWebhookInfo
You'll see a property called pending_update_count. It should zero or close to it.

Resources