Hey there, I'm Jason! As part of the process of learning chatbots I thought I'd share what I'm learning, attempting, and working on. Since I'm just learning, it's not always the right to handle stuff, so don't take it as gospel!
View All How to Program Primobot Chatbots Posts

Written by Jason Logsdon

How Primobot Chatbot is Structured with Client and DialogFlow Handling

I've been implementing a chatbot using Python to manage the backend and DialogFlow to handle the natural language processing. Trying to learn python and DialogFlow at the same time has definitely been a challenge.

For multiple reasons I want the app to serve as the main webhook point for the clients. Mainly because I'd like to keep it decoupled from DialogFlow, and since I'll most likely have multiple types of clients (facebook messenger, alexa, twitter, web chat, etc) and multiple clients of each type (many facebook pages, several skills, etc) I'd rather have 1 central location I can point everything to in case I need to change it later.

I'm definitely nervous about being reliant on outside entities after going through the huge pain of switching from Stats Inc to the local NFL feeds when we sold FanNation to Sports Illustrated, so I try to avoid it whenever possible.

There will also be a lot of customization depending on where the requests are coming from. I'm pretty sure this could all be handled in the DialogFlow webhook, I wanted to also leave the possibility open to manage it directly from the client webhooks.

To make things easier on myself, I've started calling it the Primobot Client Handler (PCH) and Primobot DialogFlow Handler(PDH).

The Primobot Client Handler flow is:

  • User enters in a query into Facebook/website chat/text/any other client
  • Query is sent to the PCH
  • PCH does some light processing and then passes it along to DialogFlow
  • DialogFlow Magic:
    • DialogFlow processes it to the correct intent, which usually sends a webhook request to PDH
    • PDH processes the webhook request, looks up information in the database, etc and sends back a response
    • DialogFlow lightly processes that response
  • DialogFlow sends a response back to the PCH
  • The response is lightly formatted and sent to the user via their client

I was originally struggling with this because the two processes kept merging in my head since the code was right next to each other. Once I split it up into Client Handling and DialogFlow Handling it started to become much more clear to me. They are definitley disctinct processes and should be handled completely differently. They wouldn't even need to be served by the same app.

We'll see where it goes from here!

Let me know in the comments below.
Jason logsdon headshot Hi, I'm Jason Logsdon! I'm an adventurous home cook and the head writer and photographer for Amazing Food Made Easy. I grew my income to 6-figures by focusing on serving my Fans by providing massive value, and I want to help you do the same.

Related Makin' Bacon Articles

All tags for this article: