• 0

Microsoft Teams: Create a new message in a channel


 Share

Question

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 Try

This 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
Share on other sites

1 answer to this question

Recommended Posts

  • 1

This was fixed btw. It seems I needed to added a trust for the serviceurl.

 

Or my service url.

 

Truth be told, to hell with the specifics. It works.

 

The command that helped, to be added before the connector:

 

            MicrosoftAppCredentials.TrustServiceUrl

 

Link to comment
Share on other sites

This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By zikalify
      Microsoft to launch Teams Phone with Calling Plan for businesses in the new year
      by Paul Hill



      Microsoft has announced that it’ll be merging Microsoft 365 Business Voice – a cloud-based phone system for small and medium businesses (SMBs) built for Microsoft Teams – with its Enterprise offerings into a new SKU called Teams Phone with Calling Plan. The new plan aims to simplify the purchase decision process and streamline the delivery of Enterprise-grade capabilities for SMBs.

      Describing the product, Microsoft said:

      Businesses that are interested in the plan will be able to buy it in 33 markets through partners from January 1, 2022. If you want to purchase the plan from Microsoft directly, you will be able to do so from January 3 if your business is in the U.S., UK, or Canada. Businesses in other markets can get the plan through Microsoft later in January.

      With the service plan, businesses will be able to make secure, reliable, and rich calls while benefiting from features such as auto-attendants, call queues, consultative transfer, and voicemail transcription. The plan leverages Microsoft’s cloud infrastructure which provides reliable high-quality audio as well as AI-powered capabilities. Businesses that use other Microsoft 365 or Office 365 services will be able to manage this plan through the same admin console.

    • By Usama Jawad96
      Meta partners with Microsoft to offer Workplace integration with Teams
      by Usama Jawad

      Meta (formerly Facebook) has an enterprise communication platform called Workplace, which had over seven million paid subscribers back in May. It is meant to be a rival to Microsoft Teams, which had over 145 million daily active users around the same time. Today, Meta and Microsoft have announced a partnership through which they will be integrate the two communication platforms.

      There are essentially two facets to the integration. The first is that Workplace content will be synced to Teams so that you don't need to jump between two apps to communicate with people using both platforms. Secondly, customers will be able to stream from Microsoft Teams into Workplace groups, which means that they can join a virtual meeting from any app and even watch its recording on Workplace later.

      Jeff Teper, CVP Product & Engineering at Microsoft Teams had the following to say about the collaboration:

      This announcement is the latest in Microsoft and Meta's joint effort to develop tools that can allow their respective customers to communicate and collaborate with each other securely. Workplace already integrates with SharePoint, OneDrive, and Office 365 apps, but this new integration will further solidify the working relationship between the two companies and provide flexibility to their joint customers.

      The sharing of content between Workplace and Teams is live as of today, but the ability to stream meetings from the latter to Workplace groups will become available in early 2022. You can start trying out the integrations today.

    • By Usama Jawad96
      Microsoft Weekly: Love from Sega, broken Windows services, and Ignite news galore
      by Usama Jawad

      We are done with another week and it's been an eventful one due to Microsoft's fall 2021 Ignite event. The company had new stuff to announce across its broad range of services and there's plenty of stuff that developers and enterprises can be excited about. It wasn't all good news throughout the week though. Quite a few services and apps in Windows broke, with fixes issued for most in a relatively short amount of time. Find out more about all this and more as we unpack the week from October 31 - November 5.

      Microsoft Fall 2021 Ignite conference


      We start this week off with Microsoft's Ignite conference. Frankly, there's just so much to cover that this section would be insanely long so we'll only highlight some of the major announcements, and if you're interested, you can always head over to the associated hyperlink or the dedicated section here to read each announcement in more detail.

      In terms of highlights, Microsoft finally announced a stable build of Edge for Linux and open-sourced the backend of its Power Fx low-code programming language. In related news, the Power Platform received deeper integration with Microsoft services such as Teams while Power Apps transitioned to pay-as-you-go (PAYG) per-app licensing along with mobile apps in preview.

      Additionally, Microsoft unveiled Loop as a new app with portable elements that you can utilize with other services to enhance workflows. HoloLens 2 is available at a 15% discount for the next few days and we finally have a preview of SQL Server 2022. Microsoft has described it as its most "cloud-connected" release yet due to integrations with Azure.

      Talking about integration, Teams is being enhanced with Mesh so that enterprises can conduct meetings in virtual, immersive worlds with customized avatars. In the same space, Microsoft also detailed how it is making it easier for IT admins to manage deployments of Windows 11, both on-premises and on the cloud via Windows 365.

      You can read more about Microsoft's Ignite 2021 in our dedicated section here.

      Microsoft loves Sega
      In a bit of a surprise announcement, Sega announced that it is exploring a partnership with Microsoft through which the two will collaborate to build "Super Games" in a "next-generation development environment". While no concrete details have been revealed as of yet, it appears that Sega will be using the power of Microsoft's cloud platform to build large-scale games that are online, global, and community-focused. Who knows if this will lead to an acquisition, eh?

      In other news, it's a big month for Xbox Game Pass too. Several high-profile releases including Minecraft: Java and Bedrock Editions, It Takes Two, Forza Horizon 5, Football Manager 2022, and Grand Theft Auto: San Andreas - The Definitive Edition have made their way to Game Pass or will be launching on the service in the next few days. Microsoft has also revealed that the Sega-published Total War: Warhammer III will be heading to Xbox Game Pass for PC on day one.

      Talking more about games, we learned that Forza Horizon 5 is becoming more accessible as Microsoft is introducing on-screen American and British Sign language for in-game cutscenes. The company also revealed more details about its upcoming AAA title Halo Infinite, saying that it will feature $10 Battle Passes with non-canon rewards. Interestingly, the Battle Passes won't expire but you can only activate one at a single instance.

      In a bit of bad news, DRM seems to breaking games on Windows 10 and Windows 11 Alder-Lake PCs, but there's a workaround available. Intel has also published a full list of games affected by the problem.

      Windows woes


      It was a not-so-good week for Windows updates unfortunately. We learned that printing is broken (again!) on Windows 10 and Windows 11. This area has been an ongoing headache for Microsoft since the emergence of PrintNightmare back in July. This time, the issue is some updates in October's Patch Tuesday which break network printing. A fix is still in development but Microsoft has provided temporary workarounds until then. Here's to hoping that Microsoft gets this resolved in this month's Patch Tuesday.

      That's not all, though. The expiration of a digital certificate in Windows 11 led to several native apps such as Snipping Tool and Touch Keyboard failing to launch. Thankfully, Microsoft released a fix for all versions of Windows 11 via Windows Update within a few hours.

      On the good side of the fence, Microsoft released build 22494 to the Windows 11 Dev Channel. Most importantly, it packs a new mute button for Teams directly in the Taskbar and also features some UI enhancements to the default apps section. There are tons of other fixes plus some known issues in this build too and you can find out all about them here. Finally, while it is not tied to the latest Dev Channel build, Insiders on that ring can now try out Android apps on the operating system.

      Dev Channel
      Microsoft is finally looking to improve the dark mode in Windows Search Support for the OneDrive desktop app on Windows 7, 8, and 8.1 is ending next year Microsoft has emphasized that capturing telemetry is essential in establishing a Zero Trust architecture Dynamics 365 gets new services in preview and GA, enhancements for existing ones Teams now features better harassment detection Microsoft's Customer Experience Platform is now official Microsoft Defender for Business is coming soon Microsoft SQL Server on Ubuntu Pro is now available through Azure Under the spotlight
      If you want to stay on Windows 10 for some reason but still want some of the UI flavor offered by Windows 11, Neowin's very own Steven Parker has offered a handy guide around exactly this topic. It includes instructions for how to enable a centered taskbar, assigning friendly names to apps, and even a giveaway for Stardock's Start11!

      Our gaming-focused News Reporter Asher Madan also dove into Forza Horizon 5 which released this week. Be sure to check out his review which talks about the stellar gameplay experience, huge roster of cars, diverse environments, and much more.

      Meanwhile, in this week's combo of Closer Look, I talked about the Calendar app integration in Windows 11 - or lack thereof - and the UI updates to the Calculator app while lamenting about the fact that Microsoft takes one step forward and two steps back when it comes to Windows 11.

      Logging off
      This week's most interesting news item is not directly related to Microsoft but is worth highlighting given the wider ramifications that it may have for industry design practices. iFixit has discovered that Apple has made it more difficult for third-party repair outlets and DIY technicians to repair iPhone 13 displays without breaking Face ID. This is due to the presence of a microcontroller that is soldered underneath the display and is used to pair a new display with an iPhone. Consumers will now be forced to visit Apple technicians and will potentially be charged higher unless they have access to technicians possessing microsoldering tools and the associated technical expertise. Consumers and proponents of the "right to repair" movement will be hoping that other OEMs don't follow suit.



      If you’d like to get a daily digest of news from Neowin, we have a Newsletter you can sign up to either via the ‘Get our newsletter’ widget in the sidebar, or through this link.

      Missed any of the previous columns? Check them all out at this link.

    • By Usama Jawad96
      Mesh for Teams enables customized avatars to have meetings in immersive spaces
      by Usama Jawad

      Apart from compliance and security updates for Microsoft Teams at Ignite 2021, the company also had tons of features to announce for its online collaboration app. Perhaps the biggest announcement is that its mixed reality (MR) platform Mesh is being integrated into Teams, something that it first announced back in March.

      Essentially, Mesh will enable users to utilize personalized and customized 3D avatars that can join Teams meetings and interact with each other in an immersive space. It won't require users to turn on their cameras but interactive methods such as eye contact and live reactions will be offered for those who prefer a non-robotic interaction. Organizations are free to create their own branded spaces and lobbies where they can hold virtual meetings using Mesh.

      Customers will be able to utilize Microsoft 365 content in Mesh meetings spatially while having the peace of mind that all their data is secure. Mesh in Teams will be available for users on PC, mobile, and mixed-reality headsets as a preview in the first half of 2022.

      Microsoft is also making it easier to collaborate cross-organization via Teams through shared channels (preview in early 2022) and the ability to chat with a personal Teams account (available by end of 2021). Customers who utilize Teams Rooms and devices have the following features to look forward to over the next few months: Direct guest join, the ability to manage Surface Hubs from Teams admin center, a new hotdesking experience with the upcoming Yealink deskVision AIO24 display, and a Logitech Tap Scheduler that will enable people to check meeting room availability and details at a quick glance.

      New apps and enhanced Power Virtual Agents are coming to Microsoft Teams as well and SaaS applications using Teams can now embed collaborative content. A new Microsoft Teams App store UI revamp will become available by the end of this month with better categorization, curated editorials, and intelligent recommendations.

      Meanwhile, customers who utilize Teams' broadcasting and webinar capabilities have lots of stuff to look forward to in the coming months as well. These include a virtual green room, enhanced management controls, co-organizers, Q&A in Teams, isolated audio feeds, and integration with Cvent.

      Microsoft is also making it easier for IT admins to manage Teams using the Teams admin center with a new device analytics dashboard, a workspace view, and priority account notifications and alerts.

      Finally, people who utilize Teams chat can now send messages to themselves, choose different views to select the density of messages on a single screen, use over 800 3D emojis, delay the delivery of messages like Outlook, and take advantage of a revamped search UI.

    • By Usama Jawad96
      Teams now features better compliance policies and harassment detection
      by Usama Jawad

      Microsoft had a bunch of developer- and enterprise-focused announcements at its Ignite 2021 conference. Among those were also some details related to enhancements coming to Microsoft Teams.

      First of all, Microsoft Records Management now offers better integration with Teams. This enables configuration of adaptive policy scopes for groups within Teams, as well as separate retention policies for attached files stored on SharePoint of OneDrive with messages. Both of these capabilities are in preview right now. However, retention policies for private channels in the collaboration app are generally available as of now.

      Teams also features enhanced integration with Communication Compliance. It ties better into shared channels and also enables users to analyze contents of modern attachments. Day Zero insights are being offered and training videos offering guidance regarding how to configure Communication Compliance are being made available. Communication Compliance directly integrates with Data Loss Prevention (DLP) too. Finally, Teams can now detect harassing or threatening language in more languages including Arabic, Dutch, Korean, and Chinese (Traditional).

      In a similar vein, Endpoint DLP and Insider Risk Management now support macOS in preview. Meanwhile, Information Protection now leverages from machine learning-based trainable classifiers to automatically label files and support for named entities in conditions. This label also carries across certain file types. Finally, Microsoft also has additional APIs and connectors for its compliance solutions, even across non-Microsoft sources.