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.

Other How to Build a Chatbot Articles

placeholder image

Cookie Consent

This website uses cookies or similar technologies, to enhance your browsing experience and provide personalized recommendations. By continuing to use our website, you agree to our Privacy Policy