Not Hot Dog Bot Walkthrough

Walkthrough Level: Intermediate

What would you say if I told you there is a chat bot on the market that tell you if you have a hotdog or not a hotdog. 🌭

Fans of HBO's hit TV series, Silicon Valley, may remember Jian-Yang's hilarious "Not Hotdog" app, which has one singular purpose -- identify whether a specific photo is a hot dog or not a hot dog.

Not Hot Dog

This app from Jian-Yang and Erlich's SeeFood startup is available for download in iOS and Android, but what if I were to tell you there was a handy chatbot version that won't take up space on your phone?

Follow Along!

After you've logged into Dexter, clone this bot into your account!

Note: The HTTP requests will not send since the APIKEYs have been removed! 😈
If the bot is misidentifying your hot dog photos, try uploading a smaller photo!

Every Picture Tells a Story

Historically, it has been prohibitively expensive to translate the meaning of an image into words that humans can understand and utilize. With recent advances in computational power and deep learning, the ability to recognize objects and meaning in images is now accessible to everyday people.


In this Not Hot Dog Bot walkthrough, we will be making use of Algorithmia, a platform that offers an API of 35,000+ algorithms, functions and models that can run as microservices. Algorithmia makes it incredibly easy to experiment with cutting-edge research in your applications and allows you to take your chatbot experiences to the next level.

By using Algorithmia's ObjectDetectionCOCO API, we were able to spin up this working bot in only 10 minutes!

As Easy As 1, 2, 3

Readers of our past extensive and lengthy walkthroughs will be happy to know that this walkthrough only requires 1 default topic, 3 triggers, and 1 easy macro.

Step One: Add a Catch-all

To start things off, we include our handy catch-all to handle any incoming text from users and introduce our users to what the bots. Never forget to include a catch-all in your default topic!

+ *
- What would you say if I told you there is a chatbot on the market that tell you if you have a hotdog or not a hotdog. It is very good and I do not want to work on it any more. You can hire someone else. <send> Let's start with you sending me a photo.

Step Two: Handle Incoming Media

Next, we make a trigger to handle incoming media from users. Any image that a user uploads on Facebook will automatically be stored in a url on the user variable _mediaUrl. We are specifically looking for incoming images, so we make use of conditionals to check that the media type of the uploaded image, stored in _mediaUrl matches type "image".

+ __media__
* <get _mediaType> == image => {@ algorithmia_image}
- That is not a photo, send me a photo.

Step Three: Make a Request to Algorithmia

At last, we get to the meat of the script.

Algorithmia pulls the heavy lifting here by providing an Object Recognition algorithm that can identify objects in an image (as well as their location within the image(!), which we don't use here). This model is specifically pre-trained on 90 possible labels, one of which is... "hot dog".

Perfect! We have everything we need to make a POST request to the appropriate Algorithmia API to run this algorithm. In our POST request headers, we replace the ALGORITHMIA_API_KEY with the API_KEY of our account. Then, we pass in our image url, stored in <get _mediaUrl> and run using the fastest model, "ssd_mobilenet_v1". (We've sacrificed some accuracy for speed...)

+ algorithmia_image
$ POST {"headers": {"Authorization": "Simple [ALGORITHMIA_API_KEY]", "Content-Type":"application/json"}, "body": {"image":"<get _mediaUrl>", "model": "ssd_mobilenet_v1"}}
- <call>checkHotDog</call>

Step Four: Check for Hot Dog

There's a little bit of code here, but we promise it's not too bad. checkHotDog is a macro that does a couple of simple things:

Pro Tip: What are those funny little underscores(i.e. "_") I see left and right in this macro?

We use lodash here at Dexter, which is available to you in your botscript macros as well! To all the developers out there using Dexter, you're welcome. 😉
> object checkHotDog javascript
  boxes = _.get(this.httpData, "result.boxes")
  hotdog = _.find(boxes, {label: "hot dog"});
  if (!hotdog)
    return "This is not a hot dog.";
  confidence = _.get(hotdog, "confidence");
  if (confidence >= 0.5)
    return "This is a hot dog.";
    return "This is not a hot dog.";
< object

Pizza or Not Pizza?

If you had no limits to the kind of chatbot you could create, what would you build?

Our team at Dexter want to give you the tools you need to build any chatbot you dream up, even if the idea is as simple as this one. That's why we're so excited to highlight these APIs from Algorithmia, which is democratizing access and usage of algorithms to everyone.

Above, you saw how we were able to use one line of $ "code" to make a simple POST request to an Algorithmia object recognition API to do a task that would traditionally require extensive developer time and resources. How else could you use Algorithmia and Dexter together in your chatbots?

Whatever you end up building, let us know by dropping us an email at 👍