I'm trying to get the slack UserId of the user who initiated a conversation with a bot.
I tried using users.identity scope and api, but I'm only getting the UserId of the user who created the bot. The bot will be used by multiple users so I want to have an isolated chat for each user by getting the exact UserId of the user who is currently having a conversation with the bot.
I'm using Python, Amazon Lex and Slack.
Can somebody point me to the right path?
If the conversation is initiated as a direct message with the bot, you can subscribe to message.im event. You'll receive this event every time a user sends a message to the bot. In the response JSON body, event.user should provide you the userId.
It could be a different solution depending upon how you are making the app, and where do you need this information.
Related
I created a telegram bot and added it to my telegram channel. Now, I want to use it to send messages to my channel, when something is happening in my python program. For example, I have a python program that checks the weather every 15 secs, and when there's a change in the weather, I want my bot to send the new weather information to my telegram channel.
So my question is, how can I do it? I'm stuck because python-telegram-bot requires a message from the user to get triggered, or a scheduled orders, while I can't schedule it because I don't know when the weather will change.
The easiest method to do this is to use the request method.
Telegram provides a cool API to send messages with your bot, you need to do that with a link for example :
https://api.telegram.org/bot<yourbottoken>/sendMessage?chat_id=<yourchatid>&text=Hello World!
What this does is that it will send the Hello World message to a certain chat id.
If you don't know how to get a chat id, you need to DM your bot and you can use this link :
https://api.telegram.org/bot<yourbottoken>/getUpdates
In the page, there will be quite a lot of JSON data, you need to use Control + F and search for your telegram username without the # and search for the chat id
If you want to do this in a python code, you need to use the requests module.
import requests
requests.post('https://api.telegram.org/bot<yourbottoken>/sendMessage?chat_id=<yourchatid>&text=Hello World!')
I have Discord bot written on Python and I'm working on command that could show info about ur steam acc. Rn it asks for writing ID manually.
But how can I get ID of user's Steam account if user has it connected to their Discord acc? Is there any method for it?
What you are looking for is the parameter connected_accounts, this will retrieve a list of dictionaries showing the accounts connected to that user.
One thing to point out is that due to Discord limitations (bots cannot access User.Profile), discord.py does not currently allow a bot account to use this function (it will always return None), so to use it you would need to be in a user bot account, which are against Discord terms of service.
I currently wanna make a discord bot that needs information from user inside ( and outside ) the server
I have a few discord id and discord user i wanna get informations from like
profile picture,current username,last online,and online status
i have found the following website https://discord.id/ however it has recaptcha so i can't really use it for my bot however i'm curious as to how the website is able to grab those data
Use this
await client.fetch_user(user.id)
I'm using python3.6 and trying to send message to myself to start interacting in slack.
I've installed pip install slackclient and am using slackclient v2.2.1
channel ID is extracted from slack link of my account https://XXXXX.slack.com/messages/XXXXXXXXX
I would like to see Hi message in my slack account. any suggestions.
client = slack.WebClient("BOT_USER_TOKEN", timeout=30)
client.chat_postMessage(
channel='CHANNEL_ID',
text='Hi!')```
The bot user token is linked to a bot user that is created with your app. If you use the bot token you will only have access to channels that this bot user is a member of.
So to make your script work you need to do one of the following:
Use the access token instead of the bot token (that one is linked to the user that installed the Slack app)
Invite the bot user to the channel you are trying to send a message to
As you want to start with basics, I would recommend to use public channels first, which will always work.
Direct messages are a little bit more complicated. To send a direct message to a user (e.g. from your bot user to yourself) you need to first open a direct message channel with conversations.open, which will give you a new channel ID. And then use that channel ID for sending a message.
i have a telegram -bot in a group which sends messages like current weather, stock prices , news and so on. at the end of the day i want to clean up the messages sent by bot. however i unable to get the message id of the messages sent by bot using the api 'https://api.telegram.org/botxxxx:xxxxxxxxxxx/getUpdates' and hence i am unable to delete message created by bot. any updates on this issue will be appreciated
you should store the message IDs when invoking the send method (from the message object returned) and delete those messages while emptying out your message id storage later on.
This is efficient than your approach for couple of reasons. For instance, with your approach you may have to filter out other messages/updates on that channel that weren't send by the bot (if your bot isn't the only admin who posts content).