Dialogflow CX Custom Integration using Flask

This course explains how you can integrate Dialogflow CX into your Flask app.

Since it is intended mainly for teaching, you should use this series to understand what is going on instead of expecting that you will get code that you can just copy and paste into your integration.

Also remember that Dialogflow CX has no free tier.

So you cannot run this code without enabling billing for your Dialogflow CX project. You will incur costs even as you build out this integration.

So don’t waste your time on this course unless you are fairly sure you need to build a Dialogflow CX bot. (How to decide if you actually need a CX bot).

This bot used for this integration is the Vendee Bot we saw in the Dialogflow CX Beginner tutorial.

Why Flask?

I am using the Flask web framework for this example because

a) it works well 🙂

b) it is one of the best frameworks for teaching and explaining, as you will see

Why not use a client library?

I don’t use a client library in this course. Instead, I do the authentication flow using the recommended client library for all Google APIs, but use the generated credentials to make direct calls to the REST API URL.

This method provides many benefits:

  • you have more flexibility in how you design your code
  • most of the best code samples are available only for NodeJS client libraries, so for other programming languages the code samples provided by Google are at best useless and at worst enormous time sinks
  • even the NodeJS client libraries are not always up to date with most recent changes to Dialogflow such as newly introduced integrations
  • all Google client libraries are built on top of protobuf, so you need to become very good at protobuf to be able to extend the client library to do what you want.

At the cost of appearing like a braggadocio, I will say that I foresaw this problem (especially point 4) and decided against using Dialogflow client libraries in my courses.


All my course students build successful integrations which are easy to customize and do what they expect, instead of waiting on Google employees to fix their client libraries to support the latest features. 🙂

By the way, if you didn’t know, the jskeet answering that thread is the legendary Jon Skeet, who has an entire wiki dedicated to Jon Skeet facts on StackOverflow. 🙂