0
votes

I'm having an Adaptive card with a share button, on click of that button I have shared that card to other Teams channel, as of now I'm able to send the message to the same Teams channel, but while sending to other teams channel it giving me Error. Below is the code i'm using:

                    var tenantID = activity.GetTenantId();
                    var message = Activity.CreateMessageActivity();
                    message.Text = "Hello World";
                    var conversationParameters = new ConversationParameters
                    {
                        IsGroup = true,
                        ChannelData = new TeamsChannelData
                        {
                            Channel = new ChannelInfo("ID of Channel to which message is to be sent"),
                            Team = new TeamInfo("ID of team to which message to be sent", "Name of team");                         

                            Tenant = new TenantInfo(tenantID),
                            Notification = new NotificationInfo(true)
                        },                       
                        Activity = (Activity)message
                    };                
                    MicrosoftAppCredentials.TrustServiceUrl(activity.ServiceUrl, DateTime.MaxValue);
                    var connectorClient = new ConnectorClient(new Uri(activity.ServiceUrl));                  
                    await connectorClient.Conversations.CreateConversationAsync(conversationParameters);
1
What error/exception are you getting? Could you please put try can and share more details about error?Wajeed-MSFT
@Wajeed-MSFT There are 2 cases 1. Posting to same Teams channel: in this case when i run solution locally it gives me "Authentication error" and when i publish the same solution and run it on azure it works as expected 2. Posting to other Teams channel: when solution is ran locally it given "Authentication error" (same as above) and when i publish same solution on azure it gives error as "Unable to reach the app" (In teams chat window).Mayuresh Jaiswal

1 Answers

0
votes

MS Teams is quite picky (for a reason) when it comes to bot-id etc. You need to make sure that you have the same bot id configured in code and in your manifest.

On top of that, when you get the "Unable to reach the app" message, that most likely means your bot messaging endpoint (configured in the bot options on azure or on dev.botframework.com ) does not point to the correct url.

In general you can not send a message to a user who never interacted with your bot before in a 1:1 conversation and you can not send a message to any teams your bot is not added to as a member.