DialogFlow | REST API

Get your DialogFlow agent to initiate the conversation before user types a message

First published: Aug 2017 | Last Updated: Oct 2020 So let us understand the question: When you work with Dialogflow you notice that it follows the “user types something -> agent replies with an answer” sequence. Suppose you wish to get the agent to say something before the user types anything, how do you do it? Example In my CourseBot (seen above), I initiate the conversation by using the same ideas described on this page. Dialogflow Built In Welcome Events When you click inside the Event textbox in Dialogflow, you will notice in the autocomplete a bunch of CHANNEL_WELCOME events. What are these welcome events? In principle, this is the feature you should use to initiate conversations on different channels….

DialogFlow | REST API

Dialogflow REST API v2 course

I have created a course on Dialogflow’s REST API v2. In my view, this course will teach you pretty much everything you need to know to work with Dialogflow REST API v2. You can check it out here. Topics covered in the course include: different types of OAuth2 authentication how the three legged auth flow works how the service account flow works (this is what we use for Dialogflow) why use client libraries OAuth2 playground basics REST API v2 URL structure Google IAM primer Using Postman for exploring Dialogflow and other Google APIs Why you need to learn about Dialogflow middleware v1 to v2 Migration tips for different types of Dialogflow apps Total video duration: ~2 hours

DialogFlow | REST API

Client side JavaScript apps (Angular, React, Ionic etc) and Dialogflow REST API v2

I got a question from a reader: Can I use a client side JavaScript app built using Ionic with Dialogflow’s v2 REST API? It could have also been Angular, or React, or one of the other bajillion other JavaScript frameworks. 🙂 The answer to all of you: No! The workaround You need to use the concept of Dialogflow REST API middleware 1 The middleware code runs on a server 2 You need to use a server side programming language such as NodeJS 3 You will save the service account JSON file to the server folder where your code is located (or some other folder you can access from the code) 4 You will set up a ‘relay’ between your JS app…

DialogFlow | REST API

Why you need to master Dialogflow’s REST API

If you are building complex integrations for Dialogflow, odds are you need to build custom Dialogflow middleware. Custom Dialogflow middleware Let us first understand what I mean by custom Dialogflow middleware. What is custom Dialogflow middleware? Here is an example of what I mean. The 1-click web demo integration of Dialogflow doesn’t support a lot of stuff. So you can build your own custom Dialogflow middleware to get around this. This is what the middleware does in this particular use case: take the user’s message relay the message to Dialogflow using the REST API get the response from Dialogflow’s REST API process the response to provide the appropriate result Here is a little flow diagram explaining this: As an example,…

DialogFlow | REST API

Dialogflow v1 API will be deprecated in October 2019

Since there have been a few people who have asked me about this, here is the official announcement on the Dialogflow website. If you have been following my site for a while, you know that I recommended moving to the v2 API a few months back. Custom website chatbots I think this change will heavily impact those who have built custom website chatbots. The main reason is that v2 uses Google’s OAuth2 for its authentication, while you could simply use the client access token for the v1 API. In turn, this leads to a significant extra effort to create website chatbots for API v2. I would recommend everyone who is still thinking of building out custom website chatbots to do…

DialogFlow | REST API

PHP Client Library for Dialogflow v2 API: Getting started

This is a very basic tutorial for getting started with the PHP Client Library for Dialogflow API v2. I don’t cover any advanced stuff, but it should help you get started. 1 Create a new folder for your project In my case, I am just calling it quickstart. 2 Download the client secret JSON file for your v2 Dialogflow agent into the quickstart folder 2.1 Make sure v2 API is enabled 2.2 Click on the service account email address You will be taken to the Google Cloud Console. 2.3 Click on the Create Service Account link at the top of the console menu 2.4 Provide a suitable name for the service account 2.5 Select Project -> Owner in the Role…

DialogFlow | REST API

Dialogflow: Is it time to switch to v2 API?

I have been asked this question by a few folks recently. While it generally depends on the “stage” of your Dialogflow project, I think the answer is tending towards Yes already. What stage is your project on? First, what stage are you in your project? Later stage project If you are later stage in your Dialogflow project, the odds are you already know all the pros and cons of switching to v2 API, plus you are already well prepared since you will incur the heaviest cost. So I don’t think you need any suggestions from me (and odds are, if the project is already somewhat mature, you are probably not the intended audience for this blog). Recently started Here, the…

DialogFlow | REST API

Understanding Dialogflow API Integrations

I was recently asked about integrating a Dialogflow health chatbot with the Infermedica API. While I haven’t personally done this yet, I realized that I have been getting questions about API integrations recently, and they all don’t mean the same thing. Here are some of the types of APIs you will be dealing with when building Dialogflow chatbots. The API of your Dialogflow agent Dialogflow allows programmatic access to the agent you build inside your console. Consider the Chemistry chatbot I built for my Intro to Dialogflow course. I can interact with my Chemistry bot in multiple ways. For example, I could simply use what is now called the Dialogflow Simulator on the top right of the Dialogflow’s web interface (it used…

DialogFlow | REST API

Dialogflow API v2 versus v1

Dialogflow recently announced that version 2 of their API is generally available. I have been asked by some readers as to what this means for their integrations, and I have summarized it in this article. How it works v2 API is quite different from v1 API even in the way the basic system works. For v1, you had two access tokens – called client access token and developer access token. These access tokens had different levels of permission – the client access token was less powerful and meant mostly for read-only tasks, while the developer access token was a lot more powerful and meant for edits/updates/deletes. To see a comparison between the two types of access tokens, you can read…

DialogFlow | REST API

Quick tips for Dialogflow REST API users

If you are using Dialogflow’s REST API, these tips can help speed up your development. Use the Postman app If you hadn’t used it already, Postman calls itself “the complete toolchain of API developers”. For our case, Postman allows you to take the various API calls you see in the Dialogflow documentation and test these requests. For example, here is a request I created as I was working on the Chatfuel integration tutorial. But here is the best part. Once you confirm that the request is constructed properly, you can simply use the Code link at the top right and get auto-generated code for the request you just made. And the Postman app supports many programming languages: Understand what a…

DialogFlow | REST API

Dialogflow REST API v2 announced

Last week, Dialogflow announced the availability of v2 of their API. It is still in beta, and there are some fairly significant changes coming up. [Also, a quick comment that I am very glad they changed their name from API.AI before this announcement. Otherwise people will be referring to API.AI API v2 vs API.AI API v1 etc. I am guessing even Google would have been so confused by this that it wouldn’t have even been possible to search for stuff. 🙂 ] Here are the changes that I could notice straight away Access via RPC You can also use RPC and not only REST for accessing the v2 API. The documentation for RPC based access can be found here. You…