Microsoft bot builder cards imback method doesnt display text on Slack - node.js

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).

Related

Bot was not started on DialogFlow for Telegram Integration

When I put the Telegram Token in DialogFlow, I get the error Bot was not started. I have started the bot in Telegram app. How do I solve this?
let’s say we will make the bot to give answers about programming language
steps:
create new agent
create entities
create the words contained in the entities
create intents
enter training phases (DialogFlow will recognise parts of the phases containing entities you just created. it will give different colors for different entities)
set default responses
add google assistant (if needed)
add response for Google Assistant. activate Google Assistant Response. choose basic card. add the image link (we can do this later). put the search text
https://google.com/search?q=how+to+le...
add more responses (telegram, slack, web demo, twitter, facebook messenger, etc.). you will get a token for activating the integration (in this example) i use Telegram
add response to Telegram. add card. fill in the card. don’t forget to add the search terms (you can add image url later)
at action and parameters section, set prompts for responses if needed
go to integrations. choose telegram (or whatever you chose before)
follow the instructions on how to create a bot in a telegram here: https://cloud.google.com/dialogflow/d...
copy the generated token
press start
there you go! now you have your own bot :)

Why doesn't the Azure Bot Service Slack connector forward Events and Interactive Messages?

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

Ways to make a dialogflow chatbot redirect to some website for a particular intent

If a user asks a question to my chatbot eg.what is coding?....then my chatbot should direct it to a wikipedia page about coding.So how can I do it in dialogflow?More specifically if I integrate my dialogflow chatbot with a website then for a particular question....it should direct it to a particular page of my website.Can anyone tell me how to do it?
It depends on the Channel you are using.
In most channels you can not force direct the user out of the chat.
You will have to send them a LINK ( most platforms support that ) or you can send them a button or quick reply etc (Depending on the Channel you are using) where the user clicks to open up a webview inside the chat or a browser window

Handling Slack Buttons in Botbuilder/nodejs

I am using the nodejs botbuilder framework. A confirm prompt will show yes/no buttons in slack, but they don't do anything when pressed. The slackbot responds with "Hmm, that didn't work, because this app is missing a request URL. Define one here: MIP Bot"
How can I setup my botbuilder app to handle the buttons?
You need to enable "Interactive Messages" in the slack developer console by entering this "Request URL"
https://slack.botframework.com/api/Actions
Then you need to copy your slack "Verification Token" and paste that where it goes in the bot framework slack channel configuration.
My Slack buttons work - yay.

Can't message Skype bot in preview mode

I've added my Skype bot (in preview mode) to my Skype account. The Skype bot seems to be properly configured, as he respons to the OnContactAddedAsync event properly by replying a pre-defined message.
However, I cannot further test the OnPersonalChatMessageReceivedAsync handler, as I'm not able to message my bot, i.e., Skype shows me the following:
Is it because I'm not added to the bot's contact list? If so, how to add somebody to the bot's contact list using the Skype Bot SDK? I have not found any way to do so in the OnContactAddedAsync handler.
Is it because of some other reason?
You need to (forcefully) update your Skype client to the lastet version in order to make it work.
Skype v7.21.0.100 does not work.
Skype v7.21.85.100 does work.
Skype v7.22.85.107 does work.
When you add the bot to your contact list in the latter version, it automatically accepts the request and you are able to message the bot.

Resources