Use the JSON API to build incredibly powerful chatbots

Cover for Use the JSON API to build incredibly powerful chatbots

When you buy a new car, you decide which add-ons you want it to have. From an upgraded engine to a state-of-the-art navigation system, the add-ons you choose make your car more powerful and useful. When it comes to chatbots, the same idea applies.

You can build a basic chatbot in five minutes. But to make it more powerful, you’ll want to incorporate some add-ons. While many no-code add-ons are available for your Chatfuel bot (like artificial intelligence and Zapier integrations), there are developer solutions too. The JSON API for your (or your customer’s) chatbot is easily the most popular of these.

What is the JSON API?

JSON stands for Javascript Object Notation. It’s one of the most commonly used formats for data transfer for fetching real-time data from one source, bringing it back, and displaying it in another.

Data in the JSON format is passed from place to place via a fetching tool called an API. So the JSON API lets you fetch dynamic data from another server for use in your bot.

Imagine an API, like a phone line, a way for two separate entities to communicate directly. Your bot picks up the phone, calls whatever server it needs data from, and asks for it. The server answers and gives the bot the data they need in JSON format.

In Chatfuel, the API for JSON takes the form of a plugin. Here’s a simple breakdown of how the free JSON API plugin works in a bot flow:

  1. A user is chatting with your bot.
  2. The user gets to the point in the flow where you’ve placed the JSON API plugin.
  3. This plugin triggers your bot to use the API to ‘call’ the external server you specified when you set up the plugin. So it can receive the data it needs (in JSON format).
  4. The bot brings that JSON-formatted data back to Chatfuel.
  5. Chatfuel renders the data for the Messenger interface so the user can see or use it for some practical application in the flow.

Though it sounds time-consuming, all five steps happen more or less instantly. Note that coding knowledge is required to use the JSON API.

Why use the JSON API in your bot?

Simply put: because it allows you to build better bots. Let’s say, for instance, that you have a Facebook chatbot that tells users the current price of 100 different stocks. This functionality is only possible to set up with the JSON API. You’d have to create 100 different blocks in your bot, one for each stock.

Next, you’d have to look up and manually enter each price. Plus, you’d have to manually change the price in your bot when any stock changes, even by a dollar. Since stock prices fluctuate constantly, your chatbot would be outdated.

But with the JSON API, your bot could fetch information from a server that has up-to-date stock prices at all times. That way, any time a user asks your bot for the price of a particular stock, they’ll be getting fresh data on the spot.

With JSON API, your Messenger bots:

  • Save your time. It allows them to do even more on autopilot and with less manual work from you.
  • Are more helpful to users. They can provide more relevant information to users than a chatbot that only deals with static data.
  • Provide a more personalized experience. An everyday use for the JSON API is to fetch the current day or time in a certain time zone (like the user’s). That means it’s possible to personalize any user’s chatbot experience making it extra relevant and memorable.

To put JSON in even more concrete terms, let’s look at its key use cases for Facebook Messenger and Instagram.

Top use cases for the JSON API

So you’re building a chatbot for your or your customer’s business. If you want to equip it to do any of the following tasks, use the JSON API. Let’s break it down by use cases for eCommerce, sales and marketing, advertising, and others.

eCommerce

Once you integrate your eCommerce store with your Chatfuel bot, you can do things like:

  • Display your store’s real-time inventory. Using a product-recommendation chatbot for your eCommerce store? Imagine the user’s frustration if they went to your site to buy the suggested item and found it was out of stock. A prime JSON API example would be to use the API plugin to link directly to your inventory database. That way, the bot will only show available items.
  • Show up-to-date product images. If you have a large inventory of products, manually uploading all the different photos for each to your bot would be seriously time-consuming. But, as another JSON API example, you could link your Facebook bot to your photo database. That way, whenever a user asks to view a specific product, the chatbot will show the latest photos from the database. This use case works great for displaying user-generated content that’s constantly changing and being updated, too.
  • Enforce a limited-time offer. Imagine you’re running a short-term sale for your store. The JSON API can track the time, so your bot will stop offering the promotion once it has expired. You won’t have to manually delete those blocks in the bot when time is up, but customers won’t be able to redeem offers when they’re no longer valid.

Sales and marketing

  • Add bot user information to your CRM or EMS. Messenger chatbots make excellent tools for lead generation. So another answer to the question ‘what is JSON used for? ’ would be: sending that lead information directly to your third-party database. If you’re gathering email addresses, you can use the JSON API to send them right to your email marketing solution. If you’re gathering complete lead information for future follow-up, you can use the JSON API to send those details right to your CRM.
  • Display new content from your site in your bot. Add JSON API to your chatbot to display the most recent posts from your blog or make the latest news articles available for them to browse. So that your bot can instantly fetch new content from your website and display it to users. Set up a WordPress JSON API if your content is hosted there, for example.
  • Let users schedule appointments. You can use the JSON API to fetch information about your availability. Users can only book times that fall within your parameters. For example, you can set your available hours and days, make a mandatory buffer so appointments can’t be scheduled at short notice, and more. Then, of course, you can also use the API to link to your calendar so the user can actually schedule the appointment.

Advertising

  • Use JSON API to connect your chatbot with your ads. That way, you get even better results: generate more leads, collect and export their data, encourage them to purchase, and more. The reason is simple — your chatbot instantly communicates with people who click on your ads and shows interest in your brand and products.

    In Chatfuel, you can connect your chatbot to your Instagram or Facebook ads in a few clicks. Check out the video below.

Other use cases

  • Share score updates for live sporting events. The Golden State Warriors, a Chatfuel customer, did this for their fan chatbot. As a prime JSON API example, their bot fetches real-time scores for games in progress. That means users can view the most up-to-date news about the game at any time via the Facebook Messenger chatbot.
  • Display up-to-date stats for coronavirus infections. Messenger bots have been used for this purpose since the COVID-19 pandemic began. They can connect to real-time information sources using the JSON API to display current infection rates for different cities or countries.
  • Offer current weather information. Weather, API, JSON: three words on this topic that commonly go together. Suppose you want your Facebook bot to give up-to-date information about current weather and the latest forecasts. In that case, you can use a free weather API for JSON. Use the plugin in Chatfuel to link your bot to a weather database, so it can always return the most recent information to users.

How to set up the JSON API in your chatbot

The instructions for setting up the JSON API in your Messenger chatbot vary widely based on what you’ll be using it for. Remember, this is a developer plugin that requires coding knowledge. We recommend visiting our Help Center or watching the webinar below to get started.

Use the JSON API to take your chatbot to the next level

Marketing automation takes on a new meaning when the JSON API is involved. This Chatfuel plugin gives developers the power to connect chatbots to outside data sources, making for a more valuable and automated experience for your business and customers.

It’s time to start building a bot for your business. Sign up for your free Chatfuel account to get started with the first 50 conversations on us.

Put knowledge into practice
Start free trial