0

I'm currently developing an application using the Microsoft Teams JavaScript SDK v2 (TeamsJS) and I'm struggling to find a way to send large text messages to a specific user or channel. I've successfully used the selectPeople API to enable users to select recipients from a list, which returns the ID, name, and email address of the selected users. However, the next step, which involves sending large text messages to these selected individuals or channels, is unclear.

The SDK documentation does not seem to provide specific information on this aspect. I'm wondering if there's a way to use the user or channel ID obtained from the selectPeople API, alongside another API or method, to send the message. Does TeamsJS v2 offer this functionality? If so, could someone point me towards the relevant documentation or provide a code example? Any assistance would be highly appreciated.

Thank you!

Vinny P.
  • 21
  • 9

1 Answers1

1

You can't actually send a message to a channel using the JS SDK - it's main purpose is to facilitate web scenarios (e.g. Tabs). Sending messages -is- possible, and there are a few ways, just not with that piece of Teams. Some options:

  1. Incoming Webhooks - see more at https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook?tabs=dotnet

  2. Proactive Messaging - see more at https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/conversations/send-proactive-messages?tabs=dotnet

For sending to a channel, you can use options 1 or 2, with 1 being the easiest. For messaging a user directly, you need option 2, but it's a much more of a complex topic to get started with - if you choose that route, here's a more detailed answer I gave on this topic, together with links to a sample and a video covering proactive messaging, which should hopefully be useful in solving this: Sending proactive messages from an outside process to organizational users via Teams chat bot.

Hilton Giesenow
  • 9,809
  • 2
  • 10
  • 24