Teams Real Simple with Pictures: Twitter integration with Power Automate post connector retirement

This blog is part of a series on Teams. For more articles, check back often. 

Written: 02/03/2020 | Updated: N/A

Last week, it was announced in the Message centre (MC204830) that the Twitter connector for Teams had been retired as of 21/02/2020. This was a feature that I loved, and one that I had previously blogged about. Connectors still work for Yammer – and for many other apps and RSS but Twitter? Per the announcement, it now needs to be integrated via Power Automate. The good news? It can be done, the benefits are exactly the same as connectors – members of the Team no longer have to scour Twitter accounts to get the updates they need, and we also have the benefit of getting hands on with Power Automate. The bad news? It probably isn’t as simple as the Message centre makes out and some functionality is lost. Whether Power Automate will replace connectors as we move forward? I don’t know – but it certainly makes sense in terms of having all of your automation and flows sitting neatly beside one another

WHY WOULD WE DO IT?

  • To keep members of the Team up to date
  • For multiple Team members to be able to respond quickly to the latest updates
  • To save time having to scour multiple sites for news and updates

PREREQUISITES

The following is required

  • Teams licence and Power Automate licence (usually via an Office 365 licence)
  • Twitter Account (with username and password)

HOW

1.) If Twitter has been previously set up as a connector, let’s get shot of this. Go to the Team and the channel the connector is in and select connectors

TMTW1

2.) Under manage select configured

TMTW2

3.) Under the Twitter Connector, select x configured then Manage

TMTW3

4.) Select Remove

TMTW4

5.) Select Remove after adding optional information

TMTW5

6.) The connector is gone. Confirmation is provided in the channel

TMTW6

TMTW7

7.) Sign in to https://flow.microsoft.com/en-us/

TMTW8

8.) Select Create then Automated Flow

TMTW9

9.) Name the Flow, select Twitter trigger When a new tweet is posted then Create

TMTW10

10.) Sign in with your Twitter account

TMTW11

11.) Enter Twitter account password and select Authorise App

TMTW12

12.) Set who to receive Tweets from by entering from@[Handle]. If you want to receive this from multiple Twitter accounts set a comma between as shown below. If you want to receive hashtagged tweets enter #[Hashtag]. If you want to receive tweets from multiple accounts and hashtagged tweets, again seperate by comma. Once done select New Step

TMTW13

13.) Search and select the Teams action Post your own adaptive card as the Flow bot to a channel (preview)

TMTW15

14.) Set the Team and the Channel

TMTW16

15.) The message is the part which some may find more complex. As opposed to a message, what the old connector did was previously send adaptive cards so we need to build an adaptive card to enter into the Message box. To do this, I would recommend using the adaptive card designer

TMTW17

Trying to get the look and feel as close as possible to the old connector, I ended up with the following code (which can be cut and pasted into the message box)

{
    “type”: “AdaptiveCard”,
    “body”: [
        {
            “type”: “ColumnSet”,
            “columns”: [
                {
                    “type”: “Column”,
                    “items”: [
                        {
                            “type”: “Image”,
                            “style”: “Person”,
                            “url”: “{creator.profileImage}”,
                            “size”: “Small”
                        }
                    ],
                    “width”: “auto”
                },
                {
                    “type”: “Column”,
                    “items”: [
                        {
                            “type”: “TextBlock”,
                            “weight”: “Bolder”,
                            “text”: “{creator.name}”,
                            “wrap”: true
                        },
                        {
                            “type”: “TextBlock”,
                            “spacing”: “None”,
                            “text”: “Created {{DATE({createdUtc},SHORT)}}”,
                            “isSubtle”: true,
                            “wrap”: true
                        }
                    ],
                    “width”: “stretch”
                }
            ]
        },
        {
            “type”: “TextBlock”,
            “text”: “{description}”,
            “wrap”: true
        }
    ],
    “actions”: [
        {
            “type”: “Action.OpenUrl”,
            “title”: “View Tweet”,
            “url”: “{viewUrl}”
        },
        {
            “type”: “Action.OpenUrl”,
            “title”: “View User”,
            “url”: “{viewUrl}”
        }
    ],
    “version”: “1.0”
}
TMTW18

 

16.) Now, in the message box replace specific elements with Dyanmic content – namely the following

{creator.profileImage} > Profile Image URL
{creator.name} > Name
Created {{DATE({createdUtc},SHORT)}} > User Name
{Description} > Tweet Text
{viewUrl} > https://twitter.com/username/status/tweetid/
{viewUrl} > https://twitter.com/username/

TMTW21
TMTW19

 

17.) Select Save

TMTW20

 

18.) The flow is now saved

TMTW22

 

19.) Now post on Twitter

TMTW24

 

20.) The post will arrive into the channel.

TMTW25

 

Our job here is done – but there are limitations

Benefits and Limitations

Overall, this works – and I have been using it the last 72 hours without issue. However, it is not exactly the same as the old Twitter connector. It’s therefore important to outline the benefits and limitations compared with the previous one.

Regarding the limitations, if any developer or Power Automate pro can build on this and enrich the functionality outlined here I would love to get in touch. However, it is clear that it’s not simply – as the Message centre outlined – a replacement and if it can be replaced to be exactly the same as the old connector then this isn’t ready to go via a template, and it’s not straightforward from a code perspective.

The benefits of this approach are

  • Tweets can continue to be pulled into a channel
  • Tweets can continue to be pulled into a channel in a digestable manner
  • Tweets can be pulled from multiple twitter accounts and specific hashtags
  • The adaptive card approach looks like the previous posts via the Twitter connector
  • The adaptive card approach can have selection actions such as View Tweet and View User which opens Twitter to respond
  • The adaptive card approach works in Teams Desktop, Web and mobile
  • The adaptive card carries through emojis

The limitations compared with previous functionality after using the first few days

  • The Tweet text does not highlight mentions, hashtags, URL’s – looks unsupported
  • The flow posts on the hour, every hour from when it was implemented. Doesn’t look to be an option to make it quicker
  • Reply’s are tweeted which means it could get noisy if the user posts several reply’s
  • The Activity shows as Flow posting a card as opposed to Twitter posting from a user
  • Can’t like or reply however the workaround is to go to the Twitter app which is easy