How to reply to the user DM via Slack API? - python

My setup is as follows: I have Dialogflow bot added as an app. The bot interacts with Slack and Dialogflow. The script uses dialogflow_fulfillment to handles the requests to return the response back to Dialogflow. At the same time, I want the bot to interact with the users like questionaries or buttons without routing back to Dialogflow. I can get it to post messages to any specified channel using client.chat_postMessage(). However I want to the bot to reply directly to the user when the user DM the app. I am not sure how this can be achieved. Please advise.

It turns out that using one app to monitor another app is not allowed by Slack. So this was not possible. The only possible way is to merge it to one app and use event api on it.

Related

Telegram start new chat with Python

I want to start a new chat in Telegram with a Python script but I know with neither Telegram's BOT nor its API it is possibile.
I don't want the user starts the chat with a BOT before!
However I was wandering if you can achieve this in anther way. I mean, when you create a new chat with Telegram application, there will be, somehow, and endpoint which handle this request.
Why is it impossibile to create a Python script which emulates this action?
I don't want the user starts the chat with a BOT before!
This is not possible. A Bot can never start a chat, that has to be done by the user him/her self.
After the user has started a conversation with the Bot, you can send anything to the user until the user stops the conversation.

How to make the bot send out multiple messages in sequence over REST API? [Rasa]

I have a conversation where the bot send out multiple replies.
For example:
User: “Hi”
Bot: “Hello”
Bot: “How can I help you?”
Here the bot sends out multiple messages. In interactive mode this is working fine. However, after I setup the REST API (following this How to serve chatbot from server?), the bot does not send out multiple messages for obvious reasons. How can I get this working?
you can use \n\n inside a text response to split it into two messages..
Unfortunately it does not work with button response messages.
Here You can use custom actions with as many dispatcher.utter_message() events as you want..

How to save a message from a telegram chat and send other messages with your own account?

I want to build a code that save a certain telegram message, from a user, as an input (ex: "David: Hello how are you doing?") and be able to send a certain message back, with my own telegram account (ex: "Me: I'm fine! How are you?")
Is there a way I can do this in python without using a telegram bot? Because I dont think bots can actually connect to your own telegram account and send messages
Unfortunately, the only way to achieve this kind of results is by creating your own customized Telegram app, take a look at the API docs at https://core.telegram.org/api

How to login as user rather bot in discord server and run commands?

Slack API provides you two options: use app as a bot and as a logged in user itself. I want to create App that will be working as a user and run channel commands. How can I do with discord.py?
Discord.py is no longer maintained to work on user accounts, so given the recent updates in the user api, it is no longer the ideal framework which selfbots should be written in.
There are a number of selfbot api libs out there, but the best one that's written in python is this: https://github.com/Merubokkusu/Discord-S.C.U.M
P.S. selfbotting against tos - so be careful (respect rate limits and don't act like a bot)
As Wright has commented, this is against discord's ToS. If you get caught using a selfbot, your account will be banned. However, if you still REALLY want to do this, what you need to do is add/replace bot.run('email', 'password') to the bottom of your bot, or client.run('email', 'password') to the bottom depending on how your bot is programmed.

Create Slack Channel for Bot User

I'm creating a web integration for my platform, using a bot user to "log" certain events.
I would like to have a new channel/group for each event type so they get shown in a list instead of all together in one channel. For this purpose I created a bot using the python Slacker integration.
Since the slack API refuses to let me create a channel as a bot user, I would need to use to the oauth2 API to create a channel and then let the bot write stuff in it. This means I need to authenticate as a user to slack with my platform.
This feels kind of hacky since the user I'd be using (probably my own) would be in the code just to create channels for the bot.
Is there a better way to do this? Whats best practice here?
Thanks!
Yes, there is a better way.
If you use a Slack app for your app you will receive two new access tokens during installation. A bot access token and a general access token. Both will have the scopes you specified during installation, but the later will not be limited to the bot subset. Use the later to create the new channels.
You will need to go though to oauth process to install your app for your Slack team, but only once for installation. The tokens will remain valid and should of course be stored by your app.
Not sure how a familiar you are with Slack apps, but you do not need to publish your app to the Slack App directory. That is optional.
See the official page about the Add-to-Slack button, section Add to Slack Flow.

Categories

Resources