title: Proactively send message to a Team chat in Microsoft Teams using Microsoft Bot Framework V4
body: <p>I am trying to proactively send an adhoc message from my Azure hosted bot to a Microsoft Teams team chat. I have been successful in sending a message to a 1 on 1 chat a user has with a bot.</p>
  
  <p>I have seen <a href="https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bot-conversations/bots-conv-proactive#creating-a-channel-conversation" rel="nofollow noreferrer">this documentation</a> detailing how to do so, however I believe this is Bot Framework version 3. It uses the nugget package Microsoft.Bot.Connector.Teams.Models, which is no longer supported in version 4. I have not been able to find documentation for doing this.</p>
  
  <p>To be a little more descriptive:</p>
  
  <p>I have a bot that recieves POST requests from my web app with alarm data. When the bot receives one of these POST requests it forwards a message to a team chat. This this message will be sent outside any context. My code for forwarding to a 1 on 1 chat can be found here.</p>
  
  <pre><code>/// &lt;summary&gt;
      /// Forwards a message to a personal chat.
      /// The details of who to send the message to is included in the &lt;paramref name="forwardContext"/&gt;.
      /// &lt;/summary&gt;
      /// &lt;param name="forwardContext"&gt;JSON of the recipient details.&lt;/param&gt;
      /// &lt;param name="messageToSend"&gt;Text message to send to chat.&lt;/param&gt;
      /// &lt;returns&gt;A &lt;see cref="Task"/&gt; representing the asynchronous messsage forward.&lt;/returns&gt;
      private async Task ForwardMessageToPersonalChatAsync(JToken forwardContext, string messageToSend)
      {
          // Collect data from JSON input
          var restCmd = forwardContext;
          var toId = (string)restCmd["toId"];
          var toName = (string)restCmd["toName"];
          var fromId = (string)restCmd["fromId"];
          var fromName = (string)restCmd["fromName"];
          var channelId = (string)restCmd["channel"];
          var serviceURL = (string)restCmd["serviceURL"];
          var conversationId = (string)restCmd["conversation"];
          var tenant = (string)restCmd["tenant"];
          var cred_str = $@"toId: {toId}
          toName: {toName}
          fromId: {fromId}
          fromName: {fromName}
          channelId: {channelId}
          serviceURL: {serviceURL}
          conversationId: {conversationId}";
          this.logger.LogInformation(cred_str);
          this.logger.LogInformation($"Forwarding the following message to {toName}: {messageToSend}");
  
          var uri = new System.Uri(serviceURL);
  
          Dictionary&lt;string, string&gt; botCreds = this.GetBotCredentials();
          ConnectorClient connector = new ConnectorClient(uri, botCreds["App ID"], botCreds["App Password"]);
          var activity = new Activity
          {
              Type = ActivityTypes.Message,
              From = new ChannelAccount(fromId, fromName),
              Recipient = new ChannelAccount(toId, toName),
              Conversation = new ConversationAccount(false, "personal", conversationId),
              Text = messageToSend,
          };
  
          try
          {
              MicrosoftAppCredentials.TrustServiceUrl(serviceURL);
              await connector.Conversations.SendToConversationAsync(conversationId, activity);
          }
          catch (System.Exception ex)
          {
              this.logger.LogError(ex.ToString());
          }
      }
  </code></pre>
  
  <p>How can I send a proactive message to a Team chat?</p>
  
  <p>Thanks for any help.</p>