Send a Twitter Private Message or SMS

Introduction

It is possible to send Private Messages to you Twitter followers. In this project we are going to try to send a private message via Twitter, if we don’t have a Twitter-name or he/she is not following you we’ll send a Text Message.

Start

The data we use within this Flow are at least: data.client.twitter_account, data.client.name, data.client.mobile. You can use more variables to use them in personalising the messages.

Decision: Has Twitter?

The data you send to the our API contains at least the variables as mentioned above. The first Decision will check if the field data.client.twitter_account is filled with text. If this is True the Flow continues to the first Twitter App, if it is False the Flow continues to the Send SMS App.

Friendships Lookup (Twitter)

Before you can send a Private Message to a Twitter account you have to check if the Twitter-account is following you.

You can send a Screen name and/or an User ID to Twitter. Within the incoming data you receive the name, screen_name, ID, ID_str and the Connections. We are saving all the incoming data into our Data Schema. In this case it is necessary to save the ID (@data.client.twitter.id@) and the connections (@data.client.twitter.connections@) because we are using them in the following steps.

Decision: Followed by?

In this step we are going to determine if in the response of the previous step (Friendships Lookup) the text followed_by is saved in the array of @data.client.twitter.connections@. Because this is an Array we are using the following Condition:

@data.client.twitter.connections@containsfollowed_by.

New Direct Message (Twitter)

If the Twitter-account in the data is following your Twitter-account you can send the Private Message.

Fill in the User ID and/or the Screen Name of the receiver and the Text of the Private Message.

You can use variables in the Message, but make sure you are not exeeding the 140 characters once the variables are placed.

Send SMS

If there is no Twitter-account available in the data or the user is not Following your account you can send the same message via SMS (Text Messaging). In this example we always have an mobile number.

The Send SMS App is already configured with the required username and password. In the Flow you only have to fill in the To, Message and Sender. We know there is a mobile number because the Decision: Has Mobile? had already determined that, so we are using that same variable @data.client.mobile@ as the To. The body of the SMS is the Message within the body you can also use a variable, in this case @data.client.name@. This App allows you to fill in a phonenumber or a name into the Sender field.

There are two Send SMS Apps in this Flow, because the Text of the SMS differs.

End

At the End of this Flow you have either send a Private Message via Twitter or send a Text Message.