Binge-eating Bot - Herostooge.

The DialogFlow work, for the most part, is complete.

And I’ve got DialogFlow talking to a MongoDB database, by way of fulfillment. (Via a server deployed to Heroku, naturally).

So far, so good.

It was sort of a pain to get there, though. Here were my hangups.

Env pains

First, it took forever to get my environmental variables right.

I spent hours in frustration, as my server refused to connect with DF, or with MongoDB.

Tooling with the server’s code — and tool I did! — accomplished nothing. No matter what I changed, I was passing null objects back and forth, or failing to fulfill promises, or giving DialogFlow the wrong credentials.

Until, finally, I pinpointed the issue: I was failing to respect Heroku’s ENV variable conventions.

I was using double quotes for the MongoDB URI. No no no. Single quotes is what works.

And I had NO quotes around the DF string. Silly me. Double quotes are required.

Once I got those ticks in place, everything clicked together.

Heroku tripping

Once I got the DF <-> Heroku <-> Mongo connection established, I had it fixed in my mind. I didn’t think I had any alternative.

When some bugs came up in my fulfillment routes, I would write code, re-deploy to Heroku, and re-test to see if things worked.

Each deployment, of course, took ~5 minutes to finish.

And because I’m a “bash my head with error messages until my code works” kind of programmer, that added a LOT to my dev time.

Since DialogFlow won’t talk to local hosts directly, I didn’t think I had any choice.

I just suffered with that ~5 minute lag, over and over again, for a couple days.

Then I remembered: ngrok!

With ngrok I was able to solve the local host <-> DF connection issue, by exposing my host through an ngrok URL. That meant I was able to test my fulfillment routes locally.

Which, literally, exponentially reduced my dev time.

And thank GOD.

That’s all for now!

Further updates coming soon!