Search tweets by hashtag and post it on Slack

  1. Add and configure Twitter Search tweets by hashtag activity

    Add ‘Twitter 'Search tweets by hashtag' activity to the canvas. Connect this activity with the ‘Start’ icon , and configure it.

    On the configuration page, you will notice a few fields. Enter values in the fields as per the instructions given below.

    Twitter Access Token: In order to use this activity, first you will have to create an access token. Select 'Add new', and fill in the required details. If you have already created a token, select it from the drop-down list.

    Hashtag: Enter the hashtag by which you wish to search the tweets. Please note you need not include '#' symbol before the hashtag string.

    twitter

    Once you have entered all the details, click on 'Done'. This will take you back to canvas.

  2. Add and configure Slack Post message to channel activity.

    Add Slack 'Post message to channel 'activity to your canvas, and connect it with the previous activity. Configure this activity and enter value in the fields as per the instructions given below.

    Slack Access Token: In order to use this activity, first you will have to create an access token. Select 'Add new' , and fill in the required details. If you have already created a token, you can select it from the drop-down list.

    Select channel type: Select the type of slack channel (Public, Private group or Direct messages) on which you wish to post the tweets from the drop-down list.

    Public channel ID or channel name: Select/specify the ID or name of the public channel on which you wish to post the tweets. Clicking the ‘Refresh’ icon will fetch the list of all public channels of your Slack account—based on the access token selected—and display it in the drop-down list. You can then select the ID or name of the public channel. Alternatively, you can enter the ID or name manually, (in case you are entering the name manually, make sure to append '#' symbol to it).

    Text: Add the {{$a1.statuses[0].text}} key listed under the array output on the right hand side of the configuration window as an input for this field.

    slack

    Once you have entered all the details, click on 'Done' to return to canvas. Connect this activity to ‘Stop’ and 'Save' the flow.

    Now, whenever you execute this flow, it will search all the tweets by specified hashtag and will post the latest tweet on the specified Slack channel.

    output