Conversational bots in cloud

14 May 2019, Łukasz Maczułajtys

As mentioned in the previous article, our company uses conversational bot to improve recruitment process. See below for some stack decisions we took during development.

When exploring a new technological area, I always start from checking solutions provided on cloud platforms. They are proven and quickly available. On top of than, a big advantage of a cloud is fast setup of production ready environment.

Solution architecture

Solution architecture

Dialogflow

For our project, we chose Google’s Dialogflow as bot engine. It is hosted on Google Cloud Platform and uses their Cloud AI components.

The most important thing is that it works well in Polish. It also supports 20+ other languages. Adding a new language version is very easy.

Dialogflow has over a dozen of messaging platform integrations. We used two of them: Messenger and Google Assistant. Every communication channel can be activated by a few clicks.

The platform has also an intuitive web console with an intents editor which speeds up prototyping and development. Intents detection correction is simplified as well.

The product is, however, not free of problems. Response time limitation is set to 5 seconds thus integration with long time response systems requires additional development. Some language versions miss certain important entity types support, e.g. Polish language version doesn’t support email address recognition.

Although SDKs for many languages are available, they are still in early development (0.x versions are available). Fortunately they are open source so everyone can contribute.

Firebase

Dialogflow does NLU for us and generates simple responses. In many cases it is, however, necessary to implement some business logic, store some data etc. We chose Firebase platform and its serverless Cloud Functions for that. Main advantage of serverless architecture is a possibility to focus only on the code. You can write what you need, deploy it using one command and it works. Firebase does it perfectly.

Code is written in TypeScript. We use types where needed and have all benefits of scripting language which are very useful when generating lots of dynamic responses. Cloud Functions are based on Express.js so the codebase can be easily migrated to a standalone app if necessary.

We also used Cloud Firestore – NoSQL document database for storing data. It has useful feature for defining triggers in cloud functions.

For serving static content such as images we used Firebase Hosting.

Main issues with serverless backend for Dialogflow are functions cold starts and long database connection. In combination with short timeout it may result in no response for a user question. Therefore a traditional serverful approach might be a better choice in certain cases.

SendGrid

Our recruitment team wants to be informed when someone leaves contact information. Our bot sends email notifications using most popular SaaS solution – SendGrid. Simple SDK and 12 000 emails per month for free per GCP project is more than enough for our needs.

Costs and scalability

By now we have paid 0$ for the whole infrastructure because our current and planned traffic fits in a free tier. It doesn’t affect the solution’s scalability. It can automatically scale to handle a very big load.

Feel free to test out bot using Messenger or invoke an action on Google Assistant (only polish language is supported for now).

Tagged with: , , , ,

Hire us!

Pretius is a software development company.
We create web applications using: Java, Oracle DB, Oracle Apex, AngularJS.
Contact us to talk about how we can help you with your software project!