Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send a DM to bot creator that informs them to add the bot to a team/channel #10683

Open
esethna opened this issue Apr 23, 2019 · 22 comments · Fixed by mattermost/mattermost-redux#847

Comments

@esethna
Copy link
Contributor

esethna commented Apr 23, 2019

If you're interested please comment here and come join our "Contributors" community channel on our daily build server, where you can discuss questions with community members and the Mattermost core team. For technical advice or questions, please join our "Developers" community channel.

New contributors please see our Developer's Guide.


Notes: Jira ticket

The purpose of this improvement is to make it more clear that bot accounts need to be added to teams and channels after creation.

It involves the following user flow:

  1. When a bot account is created through the REST API or through the UI via Main Menu > Integrations > Bot Accounts, send a DM from the bot to the creator with following text:

image

Please add me to teams and channels you want me to interact in. See [documentation](https://mattermost.com/pl/default-bot-accounts) to learn more.

[ADD BOT TO TEAMS AND CHANNELS]
  1. When the user clicks on the "Add bot to teams and channels" button, the post updates to a webhook message attachment containing

Text: Please select the **team** and **channel** you would like to add the bot to.
Dropdown: Contains a list of teams the user can choose from. This uses the existing message menu component.

image

  1. When the user clicks on the dropdown, they can select a team from the list. As noted above, this uses the existing message menu component.

image

  1. When the user selects a team, a second dropdown appears letting them choose the appropriate channel within that team.

image

  1. When the user clicks on the second dropdown, a list of channels appear

image

  1. When a channel is chosen, a message is posted back to the user with text :tada: I was successfully added to **{Channel Display Name}**.

image

@hanzei hanzei added Difficulty/3:Hard Hard ticket Area/Integrations A mattermost integration (plugin, integration, etc) labels Apr 24, 2019
@hanzei hanzei changed the title [Help Wanted] [MM-14727] Send a DM to bot creator that informs them to add the bot to a team/channel [MM-14727] Send a DM to bot creator that informs them to add the bot to a team/channel May 1, 2019
@hanzei hanzei added Help Wanted Community help wanted Tech/Go Server Tech/ReactJS Web app labels May 1, 2019
@jasonblais jasonblais added Area/Bot Accounts and removed Area/Integrations A mattermost integration (plugin, integration, etc) labels May 10, 2019
@Wipeout55
Copy link
Contributor

I'll take this on!

@hanzei
Copy link
Contributor

hanzei commented May 21, 2019

Thank you very much @Wipeout55! 👍 Let us know if you have any questions.

@Wipeout55
Copy link
Contributor

Hey all, does anything need to happen when a bot is created through a plugin? It looks like the bot creator would usually be the plugin itself, but the code says it could also specify a user as the bot's owner.

@hanzei
Copy link
Contributor

hanzei commented May 24, 2019

@jasonblais ^

@jasonblais
Copy link
Contributor

@Wipeout55 good question. If the bot is created through a plugin, let's not send a DM to the user. Only send it when a bot account is created through the REST API or through the UI via Main Menu > Integrations > Bot Accounts.

This is because

  • bots created through plugins are usually managed by the plugin itself, as you mentioned
  • plugins have the ability to post to any channels via bots
  • if the plugin requires users to add the bot to various channels, the plugin can notify the relevant users as needed

@Wipeout55
Copy link
Contributor

Thanks @jasonblais!

@harshilsharma2
Copy link
Contributor

@jasonblais plugins can specify a user ID as owner ID when creating bots. This makes the specified user as the owner. Correct me if I'm wrong though.

I think as long as bot.OwnerId is one of the active user's ID, we should send the DM to that user, irrespective of where and how did the bot get created.

@jasonblais
Copy link
Contributor

@harshilsharma63 Thank you, I wasn't familiar with that. When someone creates a bot through the rest API or the UI, that person gets automatically assigned as the bot.OwnerId. Is that correct?

If so, your proposal about sending a DM to each user assigned as bot.OwnerId would actually makes sense.

(/cc @Wipeout55)

@Wipeout55
Copy link
Contributor

@jasonblais As far as I understand it, that is correct, which is why I raised the question in the first place. My apologies for not being clearer before.

@jasonblais
Copy link
Contributor

@Wipeout55 Ah okay, got it. I missed/forgot about that part. Then it makes sense to send a DM whenever a user is assigned as the bot.OwnerId.

@Wipeout55
Copy link
Contributor

Wipeout55 commented May 26, 2019

Great, I'll make sure to include that change as well. Thanks again @jasonblais and also thanks to @harshilsharma63 for helping me clarify.

A follow-up but somewhat unrelated question, who should I contact with regards to getting translations for the three(?) new strings I'll be adding to the app?

@jasonblais
Copy link
Contributor

Excellent question. You should make sure the user interface (UI) strings are included in en.json localization files. You do not need to worry about the other languages - the strings from en.json will be automatically added to the Mattermost Translation Server once merged, and translated by our localization community.

@Wipeout55
Copy link
Contributor

Oh that's cool! I will make sure to do that!

@jasonblais
Copy link
Contributor

Great, thanks @Wipeout55! Here's also a quick 10-step checklist for contributions, which might be helpful https://developers.mattermost.com/contribute/getting-started/contribution-checklist/

(Not each step may apply to your PR of course :) )

@Wipeout55
Copy link
Contributor

Wipeout55 commented May 27, 2019

Okay, so after lots of investigation I've come up with 2 ways of implementing this workflow. Both will involve creating a custom React component that will be rendered using the system_message_helper, but the amount of logic written on the front-end vs. the back-end will vary (and bear with me as I'm still new to the codebase :-) )

  1. On bot creation, a post will be created with a custom type and a message attachment that will include the first dropdown (the team dropdown) and would be populated either using a "GenericTeamChannelProvider" or mapped from the database manually. Once the add button is pushed, the attachment will be un-hidden using "isEmbedVisible" and will allow a team to be selected. Upon selection, the component would hit a new API endpoint that would update the attachment with the channels in the selected team and allow for channel selection. A second API endpoint would then facilitate the adding of the bot to the team and channel.

  2. On bot creation, a post will be created with a custom type and no message attachment, and the custom component will be responsible for rendering the MessageAttachment component manually and will fill out the dropdowns as such. It will use the existing API endpoints to perform the workflow.

Upon speaking with @hmhealey, he recommended Option 2, but I wanted to throw this out to the community to see what everyone thought.

A follow-up question: is there anything required for the mobile app? @hmhealey recommended that the message of the post inform the user that they would need to go to the web-app.

@crspeller
Copy link
Member

@Wipeout55 I agree with Harrison here. 2 seems like the way to go.

@Wipeout55
Copy link
Contributor

Thanks @crspeller for the feedback!

In regards to the mobile app, if I am going to use Harrison's solution, what should the translation string be?
I figured something like:
Please add me to teams and channels you want me to interact in. To do this, use the web app.

@crspeller
Copy link
Member

That's a @jasonblais question! (But I think that's good.)

@jasonblais
Copy link
Contributor

@Wipeout55 That looks good, just a minor tweak:

Please add me to teams and channels you want me to interact in. To do this, use the browser or Mattermost Desktop App.

and then also hide the Add bot to teams and channels button.

I'm curious if the plan to direct them to the mobile app is due to technical limitations?

@hmhealey
Copy link
Member

hmhealey commented Jun 3, 2019

The only technical limitation is that we need a fallback message like that for older versions of the mobile app and other clients like Matterhorn.

I don't think we need to prioritize adding a proper mobile component for this though since you can't actually create bot users on mobile

@Wipeout55
Copy link
Contributor

Okay I've pushed up my PR's. There's a small issue with the workflow:
After the user adds the bot to the channel, we have to update the post with the channel name. I assumed we wanted this to be persistent, so I have updated the post itself, which is kinda weird from an API standpoint as I'm doing it to update another users post.

I have a few thoughts on how to remedy this:

  1. We could probably do nothing, as I understand that bots can only be added by system administrators, so permissions isn't currently a problem.

  2. We could not have the channel name be persistent, such that when you open the DM window with the bot after leaving the screen, the control will reset to its initial position (with just the prompt and button)

  3. We could create a custom API endpoint for updating this particular post type, so that only the owner of the bot (and the system admin) could update it.

Any feedback is appreciated, thanks everyone :)

@jasonblais
Copy link
Contributor

Great, thank you @Wipeout55! I think the second option (not having it persistent) seems okay from user experience perspective, but I'll tag @asaadmahmood to see if he has any thoughts

@hanzei hanzei reopened this Jun 12, 2019
@hanzei hanzei changed the title [MM-14727] Send a DM to bot creator that informs them to add the bot to a team/channel Send a DM to bot creator that informs them to add the bot to a team/channel Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment