- 0
Microsoft Teams: Create a new message in a channel
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
Microsoft Teams is getting a controversial location tracking feature that users may hate
By Usama Jawad96,
- microsoft
- microsoft teams
- (and 6 more)
- 9 replies
- 0 views
-
Microsoft explains how it made Teams so much faster in 2026
By Usama Jawad96,
- microsoft
- microsoft teams
- (and 8 more)
- 13 replies
- 0 views
-
Microsoft confirms a new, useful Teams' app is coming very soon
By hellowalkman,
- microsoft
- microsoft 365
- (and 2 more)
- 5 replies
- 0 views
-
Here are all the new features Microsoft added to Teams in May 2026
By Usama Jawad96,
- microsoft
- microsoft teams
- (and 3 more)
- 0 replies
- 0 views
-
- 1 reply
- 0 views
-
Question
Farchord
So I am working on setting up a new (private) bot for Microsoft Teams that should be able to post messages in a channel on-demand. I already have a bot coded for Google Hangouts Chat, but Microsoft Teams is giving me a really hard time.
I've been searching for over 10 hours now all over the web, and I am very confused.
Right now, all I want to do is post cards to a Microsoft Teams Channel. So I created the connectorclient, I used the baseuri provided when the bot joined the channel (Starts with smba.trafficmanager.net) with my MSAppID and MSAppPassword. Then, I fill in as much information as I can (Maybe too much?) and I submit the information using the connector's .conversations.createconversation.
Namespaces used: Microsoft.bot.connector, Microsoft.bot.connector.teams.models
Here's the code:
Dim Connector As New ConnectorClient(New Uri("https://smba.trafficmanager.net/amer/"), "MSAPPID", "MSAPPPASSWORD") Dim conversation As New ConversationParameters Dim activity2 = Activity.CreateMessageActivity Dim bot As New ChannelAccount bot.Id = "BOTID" bot.Name = "EDD Bot Test" conversation.Bot = bot Dim chaninfo As New ChannelInfo chaninfo.Id = "CHANID" chaninfo.Name = "General" Dim teaminfo As New TeamInfo teaminfo.Id = "TEAMID" teaminfo.Name = "EDD" activity2.Text = "Test" activity2.ServiceUrl = "https://smba.trafficmanager.net/amer/" activity2.Type = ActivityTypes.Message activity2.From = bot activity2.ChannelId = "msteams" Dim tenantdata As New TenantInfo tenantdata.Id = "TENANTID" Dim teamschanneldata As New TeamsChannelData teamschanneldata.Channel = chaninfo teamschanneldata.Team = teaminfo teamschanneldata.Tenant = tenantdata activity2.ChannelData = teamschanneldata conversation.Activity = activity2 Response.Write(JsonConvert.SerializeObject(conversation)) Try Dim reqresp As ConversationResourceResponse = Connector.Conversations.CreateConversation(conversation) Response.Write("ActivityID: " & reqresp.ActivityId & ", ServiceURL: " & reqresp.ServiceUrl & ", ID: " & reqresp.ServiceUrl) Catch ex As ErrorResponseException Response.Write(ex.Response.Content & " " & ex.Response.ReasonPhrase) End TryThis is what the API returns:
{"message":"Authorization has been denied for this request."} Unauthorized
Keep in mind, I'm not even 100% sure I'm using the right method to create the channel message, I figured it was either CreateConversation or ReplyToActivity.
I gave the app Users.ReadWriteAll permissions too, so am I missing something? That error leads me to think it doesn't have anything to do with the ConversationParameters payload but something to do with authentication.
Thank you.
Link to comment
https://www.neowin.net/forum/topic/1372792-microsoft-teams-create-a-new-message-in-a-channel/Share on other sites
1 answer to this question
Recommended Posts