With the Twitter connector you can:
- Post tweets and get tweets
- Access timelines, friends and followers
- Perform any of the other actions and triggers described below
Connect to Twitter
Before your logic app can access any service, you first need to create a connection to the service. A connection provides connectivity between a logic app and another service.
Create a connection to Twitter
- A Twitter account
Before you can use your Twitter account in a logic app, you must authorize the logic app to connect to your Twitter account. Fortunately, you can do this easily from within your logic app on the Azure Portal.
Here are the steps to authorize your logic app to connect to your Twitter account:
- To create a connection to Twitter, in the logic app designer, select Show Microsoft managed APIs in the drop down list then enter Twitter in the search box. Select the trigger or action you'll like to use:
- If you haven't created any connections to Twitter before, you'll get prompted to provide your Twitter credentials. These credentials will be used to authorize your logic app to connect to, and access your Twitter account's data:
- Provide your Twitter user name and password to authorize your logic app:
- Confirm your authorization:
- Notice the connection has been created and you are now free to proceed with the other steps in your logic app:
Use a Twitter trigger
A trigger is an event that can be used to start the workflow defined in a logic app. Learn more about triggers.
In this example, I will show you how to use the When a new tweet is posted trigger to search for #Seattle and, if #Seattle is found, update a file in Dropbox with the text from the tweet. In an enterprise example, you could search for the name of your company and update a SQL database with the text from the tweet.
- Enter twitter in the search box on the logic apps designer then select the Twitter - When a new tweet is posted trigger
- Enter #Seattle in the Search Text control
At this point, your logic app has been configured with a trigger that will begin a run of the other triggers and actions in the workflow.
For a logic app to be functional, it must contain at least one trigger and one action. Follow the steps in the next section to add an action.
Add a condition
Since we are only interested in tweets from users with more than 50 users, a condition that confirms the number of followers must first be added to the logic app.
- Select + New step to add the action you would like to take when #Seattle is found in a new tweet
- Select the Add a condition link.
This opens the Condition control where you can check conditions such as is equal to, is less than, is greater than, contains, etc.
- Select the Choose a value control.
In this control, you can select one or more of the properties from any previous actions or triggers as the value whose condition will be evaluated to true or false.
- Select the ... to expand the list of properties so you can see all the properties that are available.
- Select the Followers count property.
- Notice the Followers count property is now in the value control.
- Select is greater than from the operators list.
- Enter 50 as the operand for the is greater than operator.
The condition is now added. Save your work using the Save link on the menu above.
Use a Twitter action
An action is an operation carried out by the workflow defined in a logic app. Learn more about actions.
Now that you have added a trigger, follow these steps to add an action that will post a new tweet with the contents of the tweets found by the trigger. For the purposes of this walk-through only tweets from users with more than 50 followers will be posted.
In the next step, you will add a Twitter action that will post a tweet using some of the properties of each tweet that has been posted by a user who has more than 50 followers.
- Select Add an action. This opens the search control where you can search for other actions and triggers.
- Enter twitter into the search box then select the Twitter - Post a tweet action. This opens the Post a tweet control where you will enter all details for the tweet being posted.
- Select the Tweet text control. All outputs from previous actions and triggers in the logic app are now visible. You can select any of these and use them as part of the tweet text of the new tweet.
- Select User name
- Enter says: in the tweet text control. Do this just after User name.
- Select Tweet text.
- Save your work and send a tweet with the #Seattle hashtag to activate your workflow.
View any triggers and actions defined in the swagger, and also see any limits in the connector details.