I was recently asked about integrating a Dialogflow health chatbot with the Infermedica API. While I haven’t personally done this yet, I realized that I have been getting questions about API integrations recently, and they all don’t mean the same thing.
Here are some of the types of APIs you will be dealing with when building Dialogflow chatbots.
The API of your Dialogflow agent
Dialogflow allows programmatic access to the agent you build inside your console.
Consider the Chemistry chatbot I built for my Intro to Dialogflow course.
I can interact with my Chemistry bot in multiple ways. For example, I could simply use what is now called the Dialogflow Simulator on the top right of the Dialogflow’s web interface (it used to be called the Dialogflow test console).
But you can also use it from a web demo.
Under the hood, when you use the built in web demo, you are programmatically calling the API for the agent.
The channel API
If you look under integrations tab, you will notice that Dialogflow provides a whole bunch of integrations with external messaging channels such as Slack, Skype, Twitter, Telegram etc.
How do these integrations work? Usually, all these messaging channels expose their own API. For example Facebook Messenger will have an API which will tell external applications what they should do if they want to send a message to a given Messenger user.
The Dialogflow team utilized these APIs to build out a chat interface with their Dialogflow agents.
External web API
In addition, you also have external web APIs. I have used the Internet Chuck Norris Database API to build a Chuck Norris joke bot, for example.
The important thing to understand about calling web APIs such as the Chuck Norris Joke API is that you can only do so from inside your webhook code.
In the case of the Infermedica API, you will need to call it from your webhook. Since Dialogflow imposes some limits on how long a webhook call can take before it times out (5 seconds as of this writing), you need to make sure that any API calls you make from your webhook code returns a response quickly.
The webhook itself is similar to an API
In addition, to complicate matters further, some people refer to the webhook itself as being similar to an API (it uses similar principles). Some might say, a webhook is like an API to the business logic of your chatbot. I don’t think this is common usage, but it is something that you might want to keep in mind.
You need to be clear what API you are referring to, as well as how you will use it, while talking about Dialogflow API integrations. Once you do this, it will be much easier to create your chatbot specifications.