Update: June 30, 2020
After more testing, I have details that might help someone recognize my problem.
The issue seems to be that Slack is sending data to Azure Bot Services, but that data isn't being forwarded to my code. Ive been able to use the Bot Emulator without any problems and the Azure Web Chat works fine.
I know that the Slack configuration for the OAuth Redirect URL is correct (I was able to add my bot to Slack) and the Request URL for Events is correct (they sent the 'challenge' and it's verified). I've subscribed to the exact Scopes and Events that are in the Microsoft documentation and I've verified that the Interactivity and Events options are enabled.
When a user types text in my bot's Slack channel, my app receives "message" activity and my code can send a response, so it looks like Microsoft can communicate end-to-end for normal messages. I do not receive any data when users first join my bot (like a ConversationUpdate) or if they click a button in a dialog. I can see Slack sending data when a button is pressed, it just never arrives.
As a test, I copied the Messaging Endpoint from my Azure bot settings and pasted it into Slack's Interactivity "Request URL" and when I click a button in Slack I can see the data that Slack is sending (sadly in a format that my code can't handle).
Original Post
I have a Bot Framework app (v4) that I've written in nodejs. It works well and I have an ActivityHandler that responds to people being added to a conversation and when they send messages. I was able to get pro-active messaging functioning and everything was great until I tried to get interactivity working.
I started off using some sample button code from Microsoft's documentation:
let reply = MessageFactory.suggestedActions(['Red', 'Yellow', 'Blue'], 'What is the best color?');
await turnContext.sendActivity(reply);
This works fine in the emulator, but in Slack it renders as a bulleted list. It looks like that's the way that "suggested actions" are handled in Slack.
I changed my code to use a "hero card":
let card = CardFactory.heroCard(
'What is the best color?',
undefined,
CardFactory.actions([
{
type: 'imBack',
title: 'Color Red',
value: 'Red Value'
}
])
);
let reply = MessageFactory.attachment(card);
await turnContext.sendActivity(reply);
This works okay in the emulator, except my app thinks the user typed "Red Value" and the button stays on-screen and is still clickable. I might be able to work around that, but the button doesn't work at all in Slack. It is rendered fine, but I don't get a notification in my app.
Clicking the button shows an HTTP request to:
https://{MY_SLACK}.slack.com/api/chat.attachmentAction?_x_id=f8d003c3-1592436018.632&_x_csid=NcWi3y50lFU&slack_route={OTHER_SLACK_STUFF}
And I can see that the request POSTs all sorts of data including:
payload: {"actions":[{"id":"1","name":"imBack","text":"Color Red","type":"button","value":"Red Value","style":"default"}],"attachment_id":"2","callback_id":"{MAGIC_NUMBER}:{TEAM_ID}","channel_id":"{CHANNEL_ID}","message_ts":"1592435983.056000","prompt_app_install":false,"team_id":"{TEAM_ID}"}
I'm not sure how to see anything useful in the Azure Portal - the analytics option for my bot doesn't seem to work and the activities option only says "Write a Bot Service". I don't see any sign of the message going from Slack to Azure.
I'm developing locally and configured ngrok so that my messaging endpoint in Azure could be set to https://69fe1382ce17.ngrok.io/api/messages On the Slack side of things, I've configured the Interactivity Request URL to be https://slack.botframework.com/api/Actions The Event Subscription Request URL is https://slack.botframework.com/api/Events/{MY_BOT_NAME}
What I would like is a set of buttons with different options and when the user clicks one, my bot gets some sort of "value" instead of message text. I'd also like for the button to go away so the user can't send repeated commands. It would be nice if the hero card collapsed with just the prompt being displayed.
Are there any interactive options that work for Slack and other channels?
Thanks!
Lee
I know linking to another site with no additional detail is frowned upon, but I don't have enough expertise to answer your question. I suspect the link here might move you in the right direction:
Choice Prompts are not translated over to Slack format #3974
Good luck!
Your question is multifaceted so I'll try to break it down into smaller pieces.
What's the deal with suggested actions in Slack?
Suggested actions are not supported in Slack, but the Bot Builder SDK thinks they are. This is a longstanding bug. I've just reported it again on the docs page you linked: https://github.com/MicrosoftDocs/bot-docs/issues/1742
This means you would encounter problems if you were trying to have the choice factory automatically generate the right kind of choices for your channel. You're not doing that, so you should be fine. Hero cards are supposed to work in Slack.
Why aren't hero cards working in Slack?
First I need to mention that hero cards only work with the Slack connector and not the Slack adapter. You seem to be using the connector so you should be fine.
I suspect your problem is related to how you've configured your bot's settings on the Slack side. There is a step in the Bot Framework doc that seems to be important if you want to get buttons to work. If you've followed the doc exactly and you still can't get buttons to work, it may be worthwhile to dig into the Slack API documentation.
How do I only allow a button to be clicked once?
You can update or delete the activity. There's no easy way to do this, but if you voice your support for my cards library then it can be done for you automatically.
The Slack connector actually puts a lot of relevant information in the incoming activity's channel data, and you can use that to figure out what activity the incoming activity came from. That would take some experimentation on your part.
There's another approach that works on more channels than just Slack. It's real complicated, but if you wanna tackle this then here are the basic steps:
You need to put an ID in the action data to help your bot identify the action.
You need to save the activity ID that gets returned when you send the action to Slack.
You need to associate the returned activity ID with the ID you put in the action data.
You need to retrieve the activity ID using the action data ID when the user clicks the button.
You need to use that activity ID to update or delete the activity.
Unfortunately there's no centralized guide to help you do this, but there are many examples explaining it scattered across Stack Overflow. Here is a good one: https://stackoverflow.com/a/55174866/2122672
I have a bot using Microsoft bot builder node.js sdk. I started to add hero cards to the conversation and it is working fine except that even if I use imBack type button, slack doesn't display the value of the button. However, in other channels like Skype, when user presses 'OK' say, 'OK' is also written into the chat screen as a user message, as expected
I want to know how I can have the same with Slack
Thanks
Due to the differences in the implementation between Skype (1st party partner channel) and Slack (3rd party channel), what you are asking for is not currently available as a feature.
Slack channel does not support imBack style messages. If you send an imBack on Slack, it is converted to postBack style message (message text is hidden from user).
I am working on bot technology, in my current bot project I used the skype calling feature in that I want the functionality like once bot accepted the call after that whatever I spoken with bot I want that speech in my code in the form of text.
Before posted question here I did research on google and find the below link but this link contains dial pad options but I want the functionality like instead of dial pad, I am able to speak with bot and get the that speech into my code in the form of text.
https://docs.botframework.com/en-us/csharp/builder/sdkreference/calling.html
Can you please tell me how to do that?
-Pradeep
I have very little reputation points so I cannod add a comment in this similar question.
But I need an explanation as the code is working in a different way as expected.
I would like to have a link on my website where the user can click on the whatsapp link and start the conversation with the contact.
The code I add is this:
href="intent://send/0123456789#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end
where 0123456789 were substituted with a real number subscribed to whatsapp.
But it seems working only with my contact. If I have a new number it will not work and will tell me that the contact number is not connected to whatsapp (even if it is).
How can I solve this problem?
Once this first problem is solved, I'd like to add some preformatted text to the message like: message sent from website xyz. What code should I add?
This like of code is working for Android, I need it also for iPhone, what should I use?
This other code is working on Android and on iPhone, but it doesn't allow me to add a custom contact number:
whatsapp
abid can be only an ID from a contact already saved in you phone, otherwise it will open the contact selection page in whatsapp
Please, don't share links without explanation of the content as I'm not a developer, I'm just trying to do my best following instructions of people with more knowledge.
Thank you.
As long as your explanation describes you are looking for a user to be able to Click in order to open a Chat with a specific Whatsapp active user.
Nowadays Whatsapp has emitted an API to specifically solve this needs, it's called 'Click to Chat' API and must work on all devices:
https://faq.whatsapp.com/en/general/26000030
Also, the scheme for the link you were using seems to be working correctly nowadays when used like this:
whatsapp://send?text=MESSAGE&phone=+NUMBER&abid=+NUMBER
I've created a very simple chat (one to one chat) which works by just sending TCP-packets. The way it works at the moment is just by sending and receiving messages in the terminal. I would like to create a simple GUI that shows dialogs (modal i think it's called) in Gnome like in this picture:
Gnome Modal Dialog Chat
In other words just an application that runs in the background that pops up a modal if you receive a message, and then you can type in an answer and just press enter to send it.
Does anyone have an idea how to do this? Any examples of this online?