Slack App - Is it possible to customize blocks depending on users? - slack

I'm working on a Slack App and I would like to customize some messages depending on the users who view them.
I know about chat.postEphemeral API method, but the visual rendering is not at all pleasant (at least for my app layout).
The best solution would be to add some blocks which can be viewed/customized depending on the users who view them. Is there some way to do that?
Edit:
After several researches I did a new feature proposal to enrich the messages to Slack to have something potentially new which can be helpful to someone else. Everybody is welcome to the discussion to improve the proposal.

I'm afraid not. When you're posting messages into a conversation using chat.postMessage, the content of that message is the same for all users.
You've a few options, but they really depend on your app's flow.
Use chat.postEphemeral, as you've mentioned already
Render a modal view, which gives you the User ID before you construct the view, allowing you to customise it. The downside here is that it will require some user interaction like clicking a button before you can present the modal.
Render the content inside an App Home, which again will provide user ID, but this exists outside the context of a conversation, which might be important for your app.
Other than that, I'm afraid you'll need to stick with a generic message.

Related

How to send a welcome onboarding message in Slack app

I want to send a welcome message to a user that adds my Slack app.
This is considered good practice in the official Slack docs.
What is the right way to implement this?
Should I use the app_home_opened event for that? Is there a built-in mechanism to detect if it was triggered for the first time (because I need to show the onboarding message only once)?
Are there any other events that might be useful for the use case?
Yes. You should use the App Home features on your app. Enabling the app home with some type of instructions or welcome message would be best practice. Along side this, you will subscribe your app to the app_home_opened event type which will let you know whenever a user opens your app's app home. You can then configure your app to respond to these events. Here's a video that might help with this concept.
After #sandra's response and further investigation I would like to share more details on the implementation mechanics:
A user goes through the OAuth process and is then redirected to the app home.
In the application I catch the app_home_opened event.
If the event.tab === 'home' and event.view is not set, it means that the app home is opened for the first time and we need to send the welcome message.
Send user a message (e.g. in the Bolt for JS it's await say('Welcome!')).
Publish the Home view (e.g. in the Bolt for JS it's await client.views.publish(...)).
Useful links:
Official video from Slack about App Home
Official demo app to get some ideal on implementation
Give them a warm welcome on Day 1
Make new hires feel at home with a quick tour of the place. Using integrations like onboarding assistant Greet Bot, you can automate welcome messages and reminders, and share helpful links and documents.
The ideal welcome isn’t only a nice-to-have. It’s a critical early step in the onboarding process that shortens ramp time so your people can get to full productivity fast.
2.Create #new-hires channels
When new folks join, give them a place to find answers to FAQs, access important documents, and meet other new starters. If you’re hiring on a large scale, create multiple channels to bring together all your new hires from specific time periods.
This will boost productivity and can be great for employee engagement. Your new hires will be able to meet their peers and find the essentials fast—not just company policies but recommendations for the best places to grab a bite too.
3.Make sure they hit the ground running
When you need to bring new employees up to speed on a project, one approach is to forward them a load of email threads and wish them luck.
A better way is to invite them to a project channel where they can easily find what they need—pinned posts and files, team members, and conversations—all with a scroll or a search.
4.Help them help themselves
No one wants to feel like a burden when starting a new job. Enable self-service to help new starters get answers for themselves. As an added benefit, it’ll take some heat off your HR team because they won’t have to deal with so many admin requests.
Slack integrates with the apps your people use the most to stay productive and keep on top of HR tasks—apps like Dropbox, Salesforce, G Suite, Workday, Okta, UltiPro, and more.
5.Remind them about the important stuff
You can schedule automated messages to arrive at key times, prompting your new hires to complete the next item on their onboarding checklist. No more missed deadlines, no more time spent chasing people down. Just new employees getting up to full productivity—and full confidence—as quickly as possible.

Enable / disable functionalities for users on Ms Teams custom App

I'm planning to build a custom application for Ms Teams and I wanted the app to have an 'Administration' context, reserved for some users, with charts and records management that the rest of the users wouldn't be able to see. Is there a way to accomplish this?
Is it possible to hide tabs depending on a user profile? Is there another way to accomplish this on teams?
Tks
Inside your tab you can do whatever you want - it's just a custom web app/page. The only "restriction" aside from a normal web app, is that it must implement the Teams javascript library - see here for more. However, once you've implemented that library, you can get the Teams context, which includes the user's Azure AD Id and also UPN, and you could use one or both of those to do a lookup against your database, determine the user's role, and show/hide UI elements accordingly.
However, I think you might be asking about whether the entire Tab -itself- (i.e. even the tab item inside the Teams client) can be hidden from other users. To do this, an option is to use a "private channel", just for the relevant users, and pin the tab inside there only.

How to create dynamic dialogs from REST API in botframework

I wan't to build a bot that gather its answers and questions from a rest API.
Bot: How are you?
User: I'm fine, how are you?
Bot: I'm fine, also.
So the questions from the bot (even the first one) is gathered via REST API from an external service. Also the answer of the user is sent to this service and the Bots answer "I'm fine, also" is the result of a REST request.
I've first implemented it without using dialog feature at all. Works great, but without a dialog it's impossible to finish a dialog.
Looking around for some example I could only find some with WaterfallDialog. WatefallDialogs are build with steps - and I don't know the number of steps.
Is it possible to build such a dialog or isn't botframework not designed for such things?
In bot framework V4, the dialog/conversation flow you pick for conversations is optional, and you don't need to use them (https://learn.microsoft.com/en-us/azure/bot-service/bot-service-design-conversation-flow?view=azure-bot-service-4.0). All you NEED to do is implement bot state (https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-howto-v4-state?view=azure-bot-service-4.0), so you can store either conversation data (or user data - depends on what state you need.)
I implemented conversational flow using a single activity handler and an FSM (https://en.wikipedia.org/wiki/Finite-state_machine) - I use recognizers for common dialogs (help) but for the most part, my transition handler does regex comparisons to extract keywords and then hit the next state. So, if you can graph out your FSM, and list out all your dialog options, you can build a dialog that appears conversational and natural.
I can't share code at this time, but hopefully you don't need it.

getStream - Flat Feed where multiple users can post

we are implementing stream in our application and so far we love the out of the box react components as well as the backend implementation stream ruby - this is our setup currently.
We are close to deploying a first MVP but found that it seems to be not possible to post activities to a flat feed from multiple users by default.
Our use case is that we have a group of people that want to post activities about a certain topic (think facebook groups). Therefore we create a feed for the object (lets say a company) and want each user to be able to post activities there. Our current workaround is to add the author id as additional data and add a custom header to a activity - obviously not the best solution as reactions won't work that way.
Looking around we found that this seems to not work out of the box see this issue and this question.
Is this a feature that is only available to paying customers or how can we activate it?
Thank you in advance!
When using Stream with React users can only post to their own user feed, this is a default permission policy that can be changed by Stream.
I suggest reaching to Stream support by email and ask to change the permission policy.

Cannot find "Realtime Updates setting page under Facebook Apps Setting"

I am trying to get real time posts from a facebook page and the article http://trocolate.wordpress.com/2012/12/13/realtime-update-in-asp-net-mvc-facebook-template/ talks about a way to implement it in asp .net mvc with a facebook template. It has the below section
Subscribe to changes
There are two ways to subscribe to a class of objects: you can do manually from App Settings or you can do programmatically by codes. Here let’s pick the easy one. Go to the Realtime Updates setting page under Facebook Apps Setting. I cannot seem to find this page.
When I go to the Apps – Settings, I get Basic, Advanced and Migrations tabs. Please let me know if I have missed something.
thanks
I believe that article is outdated and now Facebook doesn't let you do that from Settings.
If you read the current documentation, it says "Real Time updates are subscribed to by using the /{app-id}/subscriptions Graph API edge." It doesn't mention any other way of making subscriptions.
Maybe you should do it programmatically.

Resources