- 28 Oct 2024
- 1 Minute to read
- Print
- DarkLight
Posting a Twitter Message Using a Flow
- Updated on 28 Oct 2024
- 1 Minute to read
- Print
- DarkLight
Overview
For further information on setting up Twitter integration, see Integrating a Twitter Account.
Once Twitter Integration has been established, a Decisions environment may use a Twitter account to manually send Tweets, as a method of notification. This is achieved using a Post Tweet component within a Flow to send a message via the Twitter API; the Input is defined for the Flow and then mapped onto the Post Tweet step in the Mapping Editor
Example
In the example, build a Flow that displays a Form for entering a Tweet.
Once the user enters the message and clicks Done, the Post Tweet component uses Integration with the Twitter API to post the tweet.
Begin by creating a Flow in a Designer Folder and adding a Show Form step.
Configure the Form by adding a Text Box component along with a button, as such.
Save and Close the Form to save any changes and return to the Flow Designer.
Then, from the Show Form step's Properties tab, change the mapping for the Form's Input to Ignore; this will allow users to pass in their submitted String into the Form.
Next, attach a Post Tweet step, from the Step Toolbox > Communication > Twitter Folder, to the outcome path of the Form.
Then, connect the outcome path of that step to End step.
Next, from the Properties tab for the Post Tweet step, define the token Id Input by Constant mapping in the name of a user-defined OauthToken Id. This Input tells the Flow which Twitter API to interact with.
After defining the 'token Id', map in the tweet Input; this Input is used to determine the text that will be tweeted out on the Twitter Account affiliated with the token Id. To utilize the Input from the Show Form step, Select From Flow map the Output of the Form step, to the tweet Input.
Finally, Save and Close the Flow.
Debug
From the Flow Designer, select the Debug link from the top toolbar to enter the Debugger, then run the Flow in Full.
The Form tab displays the Form. Enter a message in the Twitter Message field then click Done.
After submitting the Form Input, there will be a slight pause as the message is posted and the Flow completes.
To validate the Flow, access the Twitter account, and view the message with the text "This message is posted from Flow."