Skip to content

Instantly share code, notes, and snippets.

@prondubuisi
Last active April 5, 2018 16:20
Show Gist options
  • Save prondubuisi/c246d0f5fee44a1c793dad4064122464 to your computer and use it in GitHub Desktop.
Save prondubuisi/c246d0f5fee44a1c793dad4064122464 to your computer and use it in GitHub Desktop.
Creating a messenger bot to display Links to English Premiership match highlights

For this week's challenge, we want to include a feature to enable bot users view Match Highlights from the English Premier League.

  • High Level Algorithm

1) Fetch data for Premiership match Highlights from Reddit

2) Sanitize data to get specific Links,Match title for match highlights from the data fetched

3) Pass data to messenger bot and display data using Messenger Carousels with webview buttons

4) If you are done with the three preceding steps, sip some Zobo

  • Low Level Algorithm breakdown

1) Fetch data for Premiership match Highlights from Reddit

  • This is achieved by making calls to reddits API, for a start signup to reddit

  • Next create An App and get APP credentials for the API call. Create App here

  • Find a wrapper for your prefered Language, then Use the wrapper to make API calls, here is a wrapper for PHP

  • You can also decide to make the API call yourself, here is a look at the documentation, another reference here

-This is what a sample API call to The SubReddit FootballHighlights we are using for the data looks like

2) Sanitize data to get specific Links,Match title for match highlights from the data fetched

  • search for only matches with title containing Premiership

  • return urls to such matches, one way of doing this is to use regex, this is what a PHP snippet regex for this looks like '/href="([\w/:?.-=]+|[\w/:.-]+)"/'. this PHP class does exactly that

3) Pass data to messenger bot and display data using Messenger Carousels with webview buttons

  • This is the messenger documentation for carousels, thankfully a webview button is included

4) Sip Zobo(have a drink)

  • You have come this far Congratulations To take a dip dive into what the code for this loks like, see this complete PHP implementation

thanks for stoping by.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment