Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@iansltx
Last active November 15, 2017 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save iansltx/ea476854dfb350b8190f6b2a29ee9efd to your computer and use it in GitHub Desktop.
Save iansltx/ea476854dfb350b8190f6b2a29ee9efd to your computer and use it in GitHub Desktop.
Build a Bot - php[world] 2017

Requirements

Thanks for picking the Build a Bot tutorial! Here's what you'll need to complete every piece of the tutorial:

Google Chrome

It's currently the only desktop browser that supports speech recognition (see the kinda-sorta-spec). Really.

If you'd rather use Chromium, you can try these instructions. Chrome uses Google Cloud Speech to do its recognition rather than handling things locally, hence the API key requirement. Which also means that you probably can't make this work in Opera/Brave/etc.

A Dialogflow api.ai account

We'll use this to allow our bot to keep context, and to allow us to communicate with the bot more conversationally, rather than via a limited set of commands. The product was renamed by Google from API.ai pretty recently, so you'll see the old name every so often.

Docker (or properly configured PHP 7.1 running locally)

The tutorial code we'll be using is containerized to avoid spending too much time getting y'all set up with a consistent PHP environment. For the curious, we'll be building a runit-managed nginx + fpm combo container straight from an Alpine Linux base. The entire container is quite small, and the build steps don't take very long or pull much data, but if you're paranoid, build the container (will link here when it's available) prior to arriving at the tutorial. The changes we'll make during the tutorial will only affect the last few layers, if anything at all, so they won't take long.

If you'd rather not install Docker, you can use php -S to get the same effect, provided you have PHP 7.1 + the proper extensions if you have the curl extension and can run Guzzle you'll be fine). To see what exact requirements are needed, look at the Dockerfile in the tutorial repo.

An ngrok account

Our application needs to expose a web hook to the outside world, and ngrok allows us to do that, including HTTPS support. The free tier is fine for what we'll be doing. HTTPS support is doubly useful because running speech recognition from within an HTTPS page goes a lot more smoothly than when the page is running on plain old HTTP.

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