suggested actions disappear after click in directline - botframework

I have configured directline channel to Microsoft bot framework v4 with node js. I have suggested actions in welcome message. when I clicked any suggested action it disappear in UI but its response receiving to bot.
var msg = MessageFactory.suggestedActions(
CardFactory.actions([
{
type: 'messageBack',
title: 'xyz',
value: 'xyzDialog'
}]),'please select choice');
await context.sendActivity(msg);
could you please guide me how can I make it appear clicked suggested action to end user?
Thanks in advance.

As per the documentation here:
Unlike buttons that appear within rich cards (which remain visible and accessible to the user even after being tapped), buttons that appear within the suggested actions pane will disappear after the user makes a selection. This prevents the user from tapping stale buttons within a conversation and simplifies bot development (since you will not need to account for that scenario).
So in short, you cannot achieve your desired outcome with suggested actions. You have a couple of options:
Handle the suggest action in your bot code and send a reply back to the user thanking them for their input (and potentially repeating their input back to them "thank you for selecting X").
Using a CardAction instead, as per this dated sample.
Use an adaptive card (the new way), there is a sample available here, along with a detailed guide.
The downside of the last two approaches is that users will be able to repeatedly click on these buttons so your bot must handle multiple submissions in the backend.

For information on Suggest action using button.
var msg = MessageFactory.suggestedActions(['x', 'y', 'z'], 'please select choice?');
await turnContext.sendActivity(msg);
also suggestedActions need IEnumerable<CardAction> see MessageFactory.SuggestedActions Method the code will be
var msg = MessageFactory.SuggestedActions(
new CardAction[]
{
new CardAction(title: "x", type: ActionTypes.ImBack, value: "x"),
new CardAction( title: "y", type: ActionTypes.ImBack, value: "y"),
new CardAction(title: "z", type: ActionTypes.ImBack, value: "z")
}, text: "please select choice");
// Send the activity as a reply to the user.
await context.SendActivity(msg);

Related

How to switch to another Teams tab calling button onclick JS/TypeScript

I am programming app with more MS Teams tabs. In first tab i have button, which should lead to switch to other Teams tab.
In TeamsToolkit I made second tab with onclick on
I'm trying to call pages.tabs.navigateToTab function:
const doClick = (evt: React.MouseEvent) => {
const tabInstance: TabInstance = {
entityId: "index0", tabName: "Personal Tab", url: "index.html#/tab", websiteUrl: "https://localhost:53000/index.html#/tab"
};
pages.tabs.navigateToTab(tabInstance);
}
but only content changes, I miss change in "selected" item in top menu:
Am I doing something wrong? Or is it even possible to manipulate "selected" item in tab list?
Another tab is another application basically (maybe not even yours, like "Files" for example or "Posts" tab). You can tell teams to activate another tab using so-called "deep links". I am not sure, how to do it with teams tookit, but with teams API you just call executeDeepLink (v1) or pages.navigateToApp (v2) with corresponding link.
Read more about deep links here:
https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/build-and-test/deep-links

Microsoft Bot framework v4 change place holder text, status message, auto scroll

Multiple questions about Bot Framework V4.
Change the input field place holder text
Change the status message
Auto scroll on new message
On new message, chat bot is not scrolling down.
This issue is already asked here - 'Auto scroll' not working On Microsoft-bot-Framework (Python SDK based)
https://github.com/Microsoft/BotFramework-WebChat/issues/1031#issuecomment-459397736
Tried the workaround solution for web chat, but with adaptive cards taking some time to load, this solution doesn't scroll down fully.
Added a timeout of 3 sec, it works, but not ideal solution as there is a lag in scroll.
My Adaptive cards json is added to https://www.qnamaker.ai/, is that the reason for delay in loading?
You can change the sendBox default text by accessing the property via store, like so:
const store = window.WebChat.createStore( {}, ( { dispatch } ) => next => async action => {
store.dispatch({
type: 'WEB_CHAT/SET_SEND_BOX',
payload: { text: 'You got this!'}
});
});
The ability to customize the timestamp is, at this time, still a feature request. If this feature would be valuable to you, I would suggest you upvote and/or add your voice to the conversation.
My strong suspicion is, yes, the lag on rendering the adaptive card is due to QnAMaker. Or, more specifically, due to an API call and needing to wait for the returned result.

Slack: How can I remove a message's action buttons without Slack appending "edited"

I have a Slackbot message that has action buttons (see here). When a user click's a button, we perform a bit of work on our server and then use chat.update to remove the action buttons and update the message's footer:
removeButtons(reply, convo, footer) {
const data = reply.original_message;
delete data.attachments[0].actions;
data.channel = reply.channel;
if (footer) {
data.attachments[0].footer = footer;
}
this.bot.api.chat.update(data, (res) => {
});
}
Everything is working great but Slack appends an "(Edited)" to the message. I see a lot of other apps doing the same, but they seem to avoid the "(Edited)" text? What are they doing differently?
I've tried setting as_user and replace_original in the chat.update call but haven't had any luck.
Slack Screenshot
There are two ways to "update" a message as result of an interaction.
Use the API method chat.update (as you described)
Respond directly to the slack request with a new message
With 2) the original message will be replaced by default and there will be no "edited" note.

Book an appointment via a bot - which cards/attachments?

I'd like my bot to take the user through the process of booking an appointment. I want almost exactly the flow show on the home page of the https://dev.botframework.com/
However I cannot seem to find the right attachment types to represent the list of buttons or the follow up details with the 'Book now' button. Can anyone tell me which types of attachment/card these are?
List of buttons:
It doesn't look like FB Messenger. On Telegram, a HeroCard without an image would look this way (separate messages). Otherwise a SigninCard may do.
Bottom card:
ThumbnailCard card = new ThumbnailCard() {
//...
};
activity.Attachments = new List<Attachment>() {
ThumbnailCard.ToAttachment()
};

facebook fb.ui apprequests with skip option?

I am trying to use the Dialog for "Invite Friends" via Javascript SDK:
function sendRequestToManyRecipients() {
FB.ui({method: 'apprequests',
message: 'My Great Request',
}, requestCallback);
}
from https://developers.facebook.com/docs/reference/dialogs/requests
This works fine for me in case the user selects his friends and submits. My question is how can I also add "Skip" button through this function and if I can also catch the event of clicking "Skip"...any suggestions are highly appreciated! Thanks!
There is an ajax request fired when apprequests is called. In the callback you will find a response.to array in case if the user selects a friend. If the user does not select it is blank. A blank array in response.to is only when the user skips the dialog box.

Resources