Slack: Bot name in sent messages - bots

I created a bot named "esmeralda". When I send a message to Slack with the token generated for this esmeralda, the message just appears to be from "bot", not "esmeralda".
Can I do something so that the message will be shown to be sent by "esmeralda" instead the "bot"?

I'm guessing you're using the Web API and therefore the chat.postMessage method?
I'm further guessing that you're not passing as_user=true as one of your parameters. Try doing that.
(If my guesses are wrong, please include the actual details of what you're doing: at least tell us what API you're using, what method you're calling, and what parameters you're passing. Ideally share code.)

Related

How to create a bot in lex/azure that respond in slack threads?

I have created 2 chatbots using AWS lex and Azure bot framework each. I have integrated them with slack and they respond to the mentions in channels.
Currently, the bot responds as a new message however I want it to respond in the slack thread of the original message posted by the user. I tried to look for articles in various places but could not find anything helpful. Does anyone have any idea on how to achieve this or a reference to a GitHub repo for a sample?
Since you are able to post replies, I am assuming that you are using chat.postMessage API.
https://api.slack.com/methods/chat.postMessage
To send the reply as a thread, all you need to do is that add thread_ts argument in the api call.
(Provide original message's ts (timestamp) value to make this message a reply.)

Slack slash command is not working in public channels unless manually added to them

I'm not sure how much detail to provide, but I'll try to put everything that I feel is relevant.
I have a slash command that I do some logic with through AWS Lambda and API Gateway. I'm using the python slackclient module and through that I'm sending messages back into slack with the WebClient. To clarify, I'm using the new bot token system Slack has come up with, not the classic bot one.
From my understanding, using a webhook to send messages in all channels in a workspace is very painful, as a webhook is provided per channel. Thus I'm using the WebClient to interface with Slack and send messages in public channels. The problem I'm facing is that unless I add my app to a channel, the command doesn't work. The Cloudwatch logs show me that the events are coming in just fine, as I see the event fine. I also see the following log by using sys.exc_info():
(<class 'slack.errors.SlackApiError'>, SlackApiError("The request to the Slack API failed.\nThe server responded with: {'ok': False, 'error': 'not_in_channel'}"), <traceback object at 0x7ff4a0dc32c0>)
Based on that, it looks to me like sending a message back into channels I've not added this app into doesn't seem to work, but I'm not sure what OAuth permissions/scopes would be needed for this. I've enabled the following scopes for the bot token:
channels:read
chat:write
commands
As per my understanding, I don't need to add any user scopes, since I want my app/bot itself to respond, and not respond on behalf of a user.
In short, my desired behaviour is to add this app to my workspace and immediately be have it reply to a slash command regardless of which public channel the slash command has been invoked from.
The current behaviour is that the app is able to get event data from all public channels when the slash command is invoked from any of them, yet it's unable to send messages in channels the command is invoked in unless it is in the channel.
Any help given would be much appreciated!
For people migrating apps from the deprecated :bot scope, the new scope is now ready.
Add chat:write.public to your Bot Token Scopes and the error not_in_channel will not be returned anymore for public channels.
Good news: with two special scopes, you can gain those abilities by asking for them explicitly. Request the chat:write.public scope and chat:write.customize scope, respectively, to gain the ability post in all public channels and adjust your app's message authorship.
https://api.slack.com/authentication/quickstart#public
I messaged Slack help, and it turns out this functionality isn't available with the new granular bot permissions yet. As per this Slack documentation:
Currently, your app must be a member of any channel it wishes to post messages to. To join a channel, request the channels:join scope and call the conversations.join method. However, apps will soon be able to post in any public channel, without gaining additional access to the channel, by requesting a new scope.
It looks like this won't be an issue when the functionality is added by Slack.

I need a method to send a direct message to some user using excel

I need to find a method to use excel to send a direct message to slack user like we use MAilto in with subject and body function to send the user email,
for example (WhatsaApp)
api.whatsapp.com/send?phone=XXYYYYYYYYYY&text=This is my message
Well if i understand correctly, you want to get info from excel and send this info to a user, well that's possible in one way, you have to be able to read excel, which i don't recommend.
i recommend Google spreadsheet for that. anyway lets not get off-topic.
then you need to know how to send message to slack, Do you know ?
i will assume not, so to send messages there is two ways,
Webhooks
Web API
method URL = https://slack.com/api/chat.postMessage
to Send Through Web API, you have to pass the following arguments:
token The Oauth2 Token you will get from slack when configuring your bot or app, Or you can use Legacy tokens instead
channel The place you want to send the message, Channel ID if it is a channel, or User ID if it is a User.
text As the name say, the message you want to send
as_user Whether you want to send the message as your name or as a Custom name, This a boolean method, Means its Only True or False
Note: To configure a custom name its in another argument we will reach.
attachments A JSON-based array of structured attachments, presented as a URL-encoded string.
username The name you want to appear as the sender of the message, only works if as_user is false, if as_user is true, it will ignore this argument.
Hope this help.
and please next time share a code so we can help, here there is not just 'I need...'
its a place where you share code and then ask 'I need...' so we can help
I have solved the issue already
Creating an APP and using the chat.postmessage

No user messages on Chatbase transcripts

I've been trying to take advantage of the Transcripts feature in Chatbase, but whenever I open a transcript all the user messages are shown as (No content).
The messages sent by the bot are all shown properly and the order of the messages is correct as well (both user and bot). On the messages report tab I can see the user messages so they are being sent across properly.
I'm sending all the messages using the generic message API, with the original text on the message field.
This has been happening consistently for me on all projects, so I'm probably doing something wrong..any ideas?
I work on Chatbase and would be happy to look into your issue. If you could please contact chatbase-support#google.com and provide the api key, the name of the bot, or the email address you used to create the account I will be happy to look into the issue for you.

BadArgument:Security token not valid for this conversation

I'm trying to use Direct Line API of microsoft bot framework,
Following steps are followed.
Got Conversation Id from application(running on node.js)
[conversationId123]
Create Conversation Token from postman
https://directline.botframework.com/api/tokens/conversation
[ConversationToken456]
Get Conversation Messages using conversationId123 & Authorization header using ConversationToken456
https://directline.botframework.com/api/conversations/conversationId123/messages
I receive
BadArgument:Security token not valid for this conversation
Did I miss something?
Hard to know what's going wrong without seeing the whole flow; though the error indicates that the token is invalid.
Here is a DirectLine sample using Node.js. You might want to use it as the baseline for your sample and I'm pretty sure you will find out the error.
I think before sending a message to the BOT you should call the URL stream that returns from the initial "Start conversation" POST request. At least that appears at the documentation
In my case, using C# I'm able to retrieve a token, then message ID and even request the bot to send me a list of activities, but I'm unable to send a message (the POST request never comes back with an answer)

Resources