Developing a bot for the Microsoft Bot Framework using PHP

We recently released our first version of our Skype bot, I thought it might be helpful to share some of our implementation details.

Our bot enables users of Invoice Ninja to easily create, update and email invoices as well as list their products. The code for the bot is available on GitHub.

Here’s an example:

invoice acme for 2 tickets, set the due date to next thursday, the deposit to 5 dollars and the discount to 10 percent

LUIS is able to parse the command into its distinct parts.


Our app can then process the intent and return the invoice.


Two core benefits to natural language input can be seen in the example:

  • Dates can be easier to select as text. I’d much rather input ‘next thursday’ than have to find it in a cramped data picker.
  • We’re able to expose fields through multiple terms. In our standard interfaces each field needs a single label however with speech we can assign multiple labels, in this case ‘partial’ and ‘deposit’.

Microsoft provide helper libraries for C# and Node but the core features are available through a REST API. When getting started I found this article to be extremely helpful, it covers authenticating with OAuth and sending messages using PHP.

LUIS can handle matching intents but the client and product names need to be matched in our app, to accomplish this we’re using a combination of similar_text and metaphone to select the best match.

When we deployed the bot to production we found that getallheaders() wasn’t available, this solution enabled us to access the authorization token.

If you have any questions comment below.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: