DialogFlow

DialogFlow tutorial: Capturing non-English names from user input

In a recent coaching call, a client of mine had some difficulty capturing names using the @sys.given-name entity. In fact, the name which he tried and which failed, was mine 🙂 He replaced the name with @sys.any and was able to capture the name. So he got curious: why not just use @sys.any everywhere? It is not a good idea, and this article will describe why.

DialogFlow

DialogFlow (API.AI) Entity Autocomplete

Update Dec 10th 2018: Template mode is now deprecated Recently, I was showing a coaching client how to use the template mode to capture a person’s name. I walked this client through how to switch to template mode, and how to use the @ symbol. Then I showed how adding a couple of letters after the @ symbol would bring up an autocomplete. That is, the fact that the autocomplete popped up on the screen was an easy way to figure out whether you are in example mode or in template mode (see below for example). As I explained this, he went Oh, so that’s what it is! I always wondered how they got that autocomplete thing to show up…

DialogFlow

DialogFlow tutorial: Setting context from your inline webhook using contextOut

One of the nicest things about the new inline webhook editor in DialogFlow is that it allows people who create tutorials to make tightly focused ones instead of wrestling with getting their webhooks deployed. The problem A little while back I wrote a post about getting the user’s complete birthdate in DialogFlow. Turns out, the issue is somewhat non-trivial. Since DialogFlow will accept a date with only a month and a day (e.g. March 15th) as a valid input for the @sys.date entity, the user may not enter a year. The real issue, of course, is that DialogFlow will automatically append the current year as the year in the entered date. This is actually not missing information, but it is…

API.AI

DialogFlow (API.AI) Push Notifications

What should I do when my DialogFlow webhook takes too long (more than 5 seconds) to respond? I have seen this question on the DialogFlow forum appear in a few different forms. Ultimately, this is the goal: You want to send an unprompted, “out-of-band” message to the end user from your DialogFlow webhook What is an “out-of-band” message? One example is a webhook which takes too long to respond. You want to send a quick “OK, working on it…” type response. And then you want to do some kind of async processing, and then send a message back to the end user when the results are available. Another example is where you are trying to send a “reminder” to the…

API.AI

DialogFlow (API.AI) tutorial: Branching a conversation based on user input

I recently came across this question on the API.AI forum: Now, this can be a little ambiguous, so the forum member clears it up with a followup comment: Do you need a webhook? So, the first question is: do you absolutely need a webhook to solve this problem? Put another way, can you avoid using a webhook? If you frame the question as “How can I avoid using a webhook?” the answer becomes a bit clearer. Split the entity I have come to realize an interesting thing about API.AI – there is actually a tradeoff between the number of entities you are willing to create and the complexity of the eventual webhook code you will be writing. To put it…

API.AI

How to get a user’s birthdate in DialogFlow (API.AI)

A reader recently asked: How do we create a script that will ask for a date of birth? My immediate thought was, “Oh, that’s easy. You just ask for the date and use the built-in system entity etc”. And quite stupidly, I also acted on that thought and sent the email out. 🙁 But that doesn’t work It is more nuanced than that. Of course! Turns out, because API.AI is so flexible in the way it parses dates, if the user were to respond to that question with just the month and the day API.AI automatically assumes the current year. Now, at the rate at which kids are adopting technology, it is possible that a kid born this year actually…

API.AI

Creating a PHP webhook for DialogFlow (API.AI)

This is intended to be a very basic, beginner’s article for getting started with API.AI webhooks using PHP. I am making the following assumptions: a. You have a website where you can run PHP scripts b. You have sufficient permissions to be able to create new folders etc on the host without too much difficulty Code sample This tutorial is primarily based on the following code sample provided on the API.AI forum: function processMessage($update) { if($update[“result”][“action”] == “sayHello”){ sendMessage(array( “source” => $update[“result”][“source”], “speech” => “Hello from webhook”, “displayText” => “Hello from webhook”, “contextOut” => array() )); } } function sendMessage($parameters) { echo json_encode($parameters); } $update_response = file_get_contents(“php://input”); $update = json_decode($update_response, true); if (isset($update[“result”][“action”])) { processMessage($update); } Note that I made…