How to Become a Chatbot Ninja in 7 Days

Module 4: Case 6.4. Daily Horoscopes via XML Feed and Dynamic content

Case 6.4. Daily Horoscopes via XML Feed and Dynamic content

Astrology is a BIG market and people love reading their daily horoscope. In this case I will show you how to send your user a daily horoscope dynamically.

What you’ll need is this:

  • PHP Script;
  • 12 zodiac images;
  • Link to an XML feed with horoscopes.

First we set up a flow where we ask for the zodiac sign of the user and put that into a custom field.

 

When all that is set up, it is time to get the script set up that catches the XML we found to load the horoscopes, read the XML file and transform that into usable JSON code. This sounds really difficult, but truth be told, PHP actually has simple functions for that. All you have to do is copy the code or download the file. Don't forget to change lines 28 and 46.

Script: You need at least a Silver Membership to be able to view this part of the content
Script: You need at least a Silver Membership to be able to view this part of the content

So now that we have a fully working horoscope feature, we can add an action to subscribe this user to a sequence where they get a daily horoscope. You can assign them automatically, or ask if they want to receive it on a daily basis.

 

Since the XML file already shows a daily horoscope, all you have to do is call the same script from within the sequence. It can consist of a couple message boxes. Clean and simple.

 

 

If you look closely, you see we UNsubscribe the user at the beginning of the sequence AND subscribe again at the end. This way it will always be subscribed again and you don't have to create a ton of the same messages. Easy!

Downloads: You need at least a Silver Membership to be able to download this content