I am in a 1:1 chat with my bot.
as part of a command, the bot responds with a card (say Card1) and a couple of action buttons. I persist the conversation id and activity id from the context.
I issue another command. In response, the bot responds with a card (say Card2) and a couple of action buttons. I have saved this conversation id and activity id also from the context.
At this point, the user may go and click an action button in Card1. I am hoping to identify Card 1 using the persisted activity id- but on inspecting the activity Id I see that its
different from the value I persisted. How do I correctly identify a Card1 to respond to its action items?
(In 1:1, the conversationId for Card1 and Card2 is the same)
Each interaction between BOT and user is an activity. So, every activity will have a different ID, meaning each time a user or BOT sends a message it will have a different activity ID.
I would assume that both card1 and card2 have different values on their buttons, if not then use some different text to identify which card button was pressed.
The BOT doesn't know that there was a button press or the user just typed in a message. BOT would treat each message separately unless there is a formflow or promptdialog.
Buttons have multiple fields such as Title or Value. You can use different value for each card. That way you would be able to identify which card it was that was clicked as the value of a button is sent back to the BOT.
Related
As example, let's say I wanted to write an app such that when the user types /movie in a channel, a list of popular movies is shown, the user selects one, and as a result a link to that movie in IMDB is inserted into the channel as text. Is something like that possible?
Many thanks.
That's possible! A slash command is the vessel for further interactivity. You can have your slash command trigger a modal (https://api.slack.com/surfaces/modals).Your modal would offer a list of options and once the user submits, your app will be notified with a view_submission payload. You can test modal payloads using the Block Kit Builder which includes options to list items.
I'm sending messages with Block elements(buttons) to users using Slack API (python-slackclient). Different users can get number of these and can click the buttons with a delay obviously, for example the next day.
I need to identify which button in which message was clicked.
After checking the documentation on Slack API pages it looks like action_id is the way to go as I can specify it in my request and assign it a unique value. I shall get the action_id back in response coming to my endpoint once user clicks one of the buttons which will allow me to match it with sent message.
Is this the correct way to achieve it? Are you aware any better way to implement this?
You can use an action_id on your button in order to tie your button to a response action.
So if you have several buttons that should all trigger the same action, but you'd still need to know which of those buttons was clicked, maybe you could give them all the same action_id (so you can link them to the same action), but specify unique button values.
You need to make sure your action_ids are unique, BUT you can receive a message or an action using RegEx and thus still point them all to the same handler.
For example, this action handler receives all button presses where the action_id starts with "hello"
app.action(/^hello.*/, async ({ body, ack, say }: any) => {
await ack();
await say(`<#${body.user.id}> clicked the button`);
});
With the "Post an adaptive card" action in Flow / Power Automate -> Microsoft Teams there's the option to specify an "update message" following the user response to the card.
How can I access the data inputs and the submitActionId for use in this message?
The use case is as follows:
user receives the card and enters data into a textfield.
user clicks one of two buttons (similar to "approve" and "reject")
(what I want to do:) card is updated to show what text the user entered and which button was pressed.
I can access other dynamic data that have been created by previous actions in the "update message" field. But the output of this adaptive card action itself is not available "within" the action, not by normal means anyway. Later in the flow it's necessary to parse the JSON output of this action.
Supplementary question: Is it possible to style the "update message". Currently it appears all bold.
Supplementary info: the "update message" field does not appear to accept another adaptive card (would have been logical...). If I enter adaptive card json there, it just gets spat back out literally in Teams.
I'm trying to create a bot, where users are able to select an option from an adaptive card, or type it in. So I am currently displaying a carousel of adaptive cards, and then using a text prompt for a possible input.
Unfortunately, since I'm using a prompt, when I click an action from the card, I get an "I don't understand" output from the bot, as it is expecting a user input.
Is there any way to achieve this?
I am currently displaying a carousel of adaptive cards, and then using a text prompt for a possible input.
I do a test and can reproduce the issue on my side. I assume that you call PromptDialog.Text method after you send an adaptive card to client for collecting user inputs, the PromptDialog.Text would expect a string, if you directly enter the input filed(s) and submit it to bot, it will send back a Activity message with your input value, which would throw "I don't understand" message and let you retry again.
If you provide a string before you enter input field(s) and submit it, your bot should work as expected.
Suppose I have different cards, or section in a page with “like” button on every card. On clicking this card, a Mixpanel “like” event is fired with some custom properties – Button Name, Card/Section name etc.
Question –
Now if I want to show the count of “like” on every card, in real – time, how can we do that. An example is – if the user clicks like on a card, the count of like for the card will increment without refreshing the page. Will it be possible to get the response of “mixpanel.track” event and in response fetch the count of “like” event and display below every card.
Currently I am using below mentioned API URL which is returning list of all entries for the specified event and property.
URL – https://mixpanel.com/api/2.0/events/properties/?name=Name of property&event=Name of Event&type=general&unit=month"
you can use the callback in mixpanel.track
https://mixpanel.com/help/reference/javascript-full-api-reference#mixpanel.track
One more thing you should do is use mixpanel.increment so like count gets stored in mixpanel as well
https://mixpanel.com/help/reference/javascript-full-api-reference#mixpanel.people.increment
Hope this helps,
Che