Creating a Subscription Broadcast in Flow XO

You might have several communication feeds that you’d like to broadcast to your users. For instance, you might want to broadcast your blog or Twitter updates. But, most of the time, you’ll only want to broadcast the feeds that each user is interested in. In Flow XO, you can broadcast feeds, and also let users customize which feeds they receive.

If you don’t already have a free Flow XO account, get yours now.

For this tutorial, you’ll create four different flows:

  • In Flow 1, you’ll ask users which feeds they’d like to subscribe to.
  • In Flows 2 and 3, you’ll broadcast different feeds. Your bot will only broadcast channels that the user subscribed to.
  • In Flow 4, you’ll give the user options to unsubscribe from feeds.

By the end, your Flows page in the Flow XO Editor will look like this:

Flow 1: Subscription Options

In the first flow, you’ll present the user with feeds they can subscribe to. Then you’ll use attributes to mark the user’s selection. The attributes that you create in this flow will be used in all the other flows for this tutorial.

If you’re unfamiliar with attributes, you may want to review our other tutorial on Attributes in Flow XO.

Create a Flow and Trigger

Follow these steps to set up your first flow:

  1. In the Flow XO editor, click + New Flow. Select Blank Flow.
  2. In your new flow, click + to add a trigger. Select Bot → New Message, then click Next.
  3. In the Words or Phrases field, type “Subscribe”. Your bot will run this flow on the word “subscribe”:

Click Next to continue, finish and Save. There is no need to add a filter to this trigger.

If the user types “Subscribe” at any point, this flow will start.

List Subscription Options

The next step is to ask the user which feeds they’d like to subscribe to. For this tutorial, we’ll use the Flow XO Articles page and Twitter channel as an example. You can use any RSS feeds you’d like.

To list subscription options:

  1. In your flow, add an action. Select Bot → Ask a Question, then click Next.
  2. Select Choice for your Question Type. Then ask your question.
  3. Under Choices, list each subscription option. You can also add Both and None as options:

Click Next to continue, finish and click Save.

When your bot runs this action, it will present the user with these choices.

Set Attributes

Next, use attributes to mark which feeds the user subscribed to (if any). You’ll need to add a separate action for each attribute, as each will have a different filter.

To set an attribute for the first feed:

  1. In your flow, add an action. Select Attributes → Set an Attribute, then click Next.
  2. In the Settings window, click + Add to add an attribute.
  3. In the Name field, give your attribute a clear name, like articles.
  4. In the Value field, type subscribed to indicate the user has subscribed to the Articles feed. For example:

Click Next to go to the Filter window.

Set up a filter so that your bot will only set articles to subscribed if the user subscribes to the Articles feed. Your bot should run this action if the user selects either Articles or Both. Here’s how to set this up:

  1. In the Filter window, set the first Value to check the output of the previous action. This was where you asked the user what they’d like to subscribe to.
  2. Set the Condition to Equals.
  3. For the second Value, enter Articles. This action will only run if the user subscribes to Articles.
  4. You also want this action to run if the user subscribes to Both. So click + OR to add a second condition for this action.
  5. For the second condition, use the same settings for Value and Condition. For the second Value, enter Both. The Filter window should look like this:

If the user selects Articles or Both, your bot will set articles to subscribed. Click Next, then Save this action.

Next, set a similar action for the Twitter subscription. A quick way to do this is to copy your previous action:

Then update the values for Twitter. Keep the filter to run this action if the user subscribes to Both.

For your final step in this flow, you might want to send a message confirming that the user has subscribed to a feed.

Your first flow is complete. Your bot will present subscription options to the user, and mark the feeds they subscribe to.

Flow 2: RSS feed for Articles

The next step is to check for updates to the Articles feed if the user subscribed to this feed. To do this, you’ll create a new flow that uses the Flow XO Broadcast trigger. When there is an update, you can display it on a card.

Broadcast Trigger

In Flow XO, the Broadcast trigger checks your RSS feed for updates. You can filter it so that it only runs if the user subscribes to the feed.

To set this up:

  1. On your Flows page, click + New Flow. Select Blank Flow.
  2. Click + to add a trigger. Select the Broadcast service.
  3. Under Trigger, select New RSS Feed Item, then click Next.
  4. Keep Broadcast to users of all bots on. Click Next.
  5. In the Settings window, paste the Feed URL to your RSS feed, then click Next:

Finally, add a Filter so that this trigger will only check for updates if the user subscribed to the feed. In this case, check if the articles attribute is set to subscribed:

Click Next, name your trigger, then click Save. Your bot will now check the Articles RSS feed for updates if the user is subscribed.

Send a Card

When there is an update to your RSS feed, your bot can display it on a card. To do this:

  1. In your flow for the Articles RSS feed, add a new action. Select Bot → Send a Card, then click Next.
  2. Set up the card to display text, images, and links from your RSS feed. Your bot will gather information from each feed item for you. To access this, type {{, then select the output to display in each field:

The data on your card will depend on what is available in your feed, and what you want to display. Here is an example of a completed card:

Click Next, then finish and save the card. There is no need to add a filter because the whole flow is already filtered.

Note: Your bot will only display a card when there is an update to your RSS feed. When you test this, you will not receive a card until the next update.

Flow 3: RSS feed for Twitter

Now, create a flow for your second feed, in this case, the Twitter feed. Instead of starting over again, you can copy the flow for your Articles feed:

Then, like the Attribute action above, you can update values for your Twitter feed:

  • Set the Broadcast URL to the Twitter RSS feed.
  • Filter the trigger so that it only runs when the attribute twitter is set to subscribed.
  • Set your card values according to what is available in your RSS feed.

Flow 4: Unsubscribe Options

For the last flow, give users a way to unsubscribe from your feeds. The setup for this is similar to your first flow.

To begin, add a New Message trigger on the word “unsubscribe”. Do this in the same way you set up the trigger on your first flow.

Next, you need information from the user so that you can change the relevant attributes from subscribed to unsubscribed.

Ask Which Feeds to Unsubscribe From

Ask the user which feeds they want to unsubscribe from. Similar to the subscription flow, Ask a Question, then list the available feeds. Once again, you can add Both and None as options:

Click Next, then finish and save the action. You’ll use the output from this action to update the attributes for unsubscribed feeds.

Update Attributes

Finally, update the attributes for the feeds that the user unsubscribed from. To do this, you’ll use Set an Attribute to overwrite the existing value in each feed attribute.

Starting with the articles attribute, set the value to unsubscribed. This will prevent the Articles flow from checking for updates:

Then set the filter so this action will only run if the user unsubscribes from Articles or Both:

Repeat this action for the twitter attribute.

For your last step in this flow, it’s a good idea to send a message to the user confirming that they have unsubscribed.

Conclusion

In this tutorial, you learned how to set up subscription options for a broadcast feed. Now your users will be able to customize which feeds they subscribe to. You can use this for any type of Broadcast in Flow XO. You can add even more customization with additional feeds, filters, and attributes.

Want to find out more? We have full documentation for the Broadcast service and other features in Flow XO over at our Help Center, or get help & advice from other Flow XO users on the Community Site.