I created an app that is a bot using the VSCode extension TeamsToolkit. This tool gives some options of the kind of app, and I chose the 'notification bot' app as that is the main purpose of my project.
This notification bot receives an HTTP request with the target information (person, group chat or team channel) and has to find the conversation reference storage configured in the teams toolkit and send an adaptive card to this target.
Every time a member installs the app, MS Teams is supposed to send a message that triggers an event to update this storage so it will be able to find the source in the future but the problem is that when installing the bot in a team, it lets me choose just one channel of this team and everything works well only for this channel. It sends the onMembersAdded event to update the storage with the channel info, and even sends a 'welcome' message (due to the sample generate by toolkit).
But I can't find a way to target notifications to other channels in the same team.
The app itself appears to be managed at the team level in MS Teams rather than the channel level. For instance, remove it is done at the team level, but in the onMembersAdded event, it saves the channel name, which makes it possible to interact only with this first chosen channel, regardless of which one you want to notify.
I've tried to uninstall and re-install the bot, choosing another channel, but this just overrides the stored information for the new channel.
Is there a way to send a message to different channels in the same team?
The instalation occurs in the team level, that is why I got welcome message only in the channel I choose when adding it to the team. But after this, all channel has access to this bot, despide they never got this welcome message.
Once I was trying to send a proactive message, I solve the problem by changing the code to use the method botAdapter.notification.findAllChannel(predicate) instead botAdapter.notification.findChannel(predicate) that really didn't work as expected on version 3.0.2 of teamsfx package.
For example, the code above was able to find every channel in a team after installation, and send proactive message to each one of them
const channels = botAdapter.notifications.findAllChannels(() => Promise.resolve(true))
console.log(channels)
for (const channel of channels) {
await channel.sendAdaptiveCard(...)
}
OBS: botAdapter is an instance of the ConversationBot of teamsfx lib and can be named the way you want to.
OBS2: Be careful with findChannel (pay attention that I indicated findAllChannels)