Integration of NLP Engine (Dialogflow) into a Mobile Chatbot
We often see projects where Dialogflow integration starts without a clear understanding of the differences between ES and CX. Clients choose ES for its simplicity, but six months later face the need to rewrite all intent logic—the State Machine architecture in CX is incompatible with the linear Flow from ES. Our task is to help you choose the right version and configure the integration so that the bot works stably from the first release. With over 5 years in mobile development, we guarantee quality at every stage.
Why the Choice of Dialogflow Version Is Critical
Dialogflow CX and Dialogflow ES are fundamentally different products. ES uses a linear flow: intents are processed sequentially, contexts live for a limited number of turns. CX is built on a State Machine: each step is a page with explicit transitions. Migrating from ES to CX requires a complete redesign of the agent. CX is better suited for complex multi-step scenarios (order placement, tech support), while ES is for simple Q&A. The choice depends on your scenarios; we offer an audit before development begins.
How to Set Up Authentication Without Security Risks
The official Google Cloud documentation suggests using a service account JSON directly in the app. This is unacceptable—the private key ends up in the APK/IPA. The correct approach: the mobile app sends text to your backend, and the backend communicates with Dialogflow via the google-cloud-dialogflow library using the service account. We implement a proxy server in Node.js or Python that processes requests and returns responses. Example in Node.js:
const { SessionsClient } = require('@google-cloud/dialogflow-cx');
const client = new SessionsClient();
async function detectIntent(projectId, location, agentId, sessionId, text, languageCode) {
const sessionPath = client.projectLocationAgentSessionPath(
projectId, location, agentId, sessionId
);
const request = {
session: sessionPath,
queryInput: {
text: { text },
languageCode,
},
};
const [response] = await client.detectIntent(request);
return response.queryResult;
}
How to Solve Multilingual and Context Issues
Dialogflow supports multiple languages on one agent, but training phrases for each language must be added separately. If you pass languageCode: ru to an agent without Russian phrases, Dialogflow returns a fallback intent with low confidence—the user won't understand the answer. We configure language sets and test them via the simulator.
Context management is a common source of errors. In ES, contexts live for N turns after being set. If you don't reset the context after a scenario ends, the user might get an unexpected response. In CX, this issue is solved by explicit transitions between pages. Our engineers design flows so that each scenario ends with a context reset for all active dialogues.
Mobile-Side Implementation
On Android, we use OkHttp or Retrofit to call the proxy server. Session ID is generated once at session start and kept in memory—not in SharedPreferences, sessions should not survive app restarts.
class DialogflowRepository(private val api: ChatApiService) {
private val sessionId = UUID.randomUUID().toString()
suspend fun sendMessage(text: String, locale: String): ChatResponse {
return api.detectIntent(
DetectIntentRequest(
sessionId = sessionId,
text = text,
languageCode = locale
)
)
}
}
On iOS—similarly via URLSession or Alamofire. No direct calls to Google API from the client. For rendering Rich responses (cards, buttons, carousels), we parse fulfillmentMessages and render the corresponding view components: TextBubbleCell, ButtonsRowCell, CardCell.
Agent Design: Practical Recommendations
For a production bot, you need:
- Group intents by domain (orders, support, FAQ) and cluster them
- Configure a fallback intent with multiple response variants (at least 5)
- Add Small Talk as a separate flow—otherwise the bot rudely ignores informal remarks
- Webhook fulfillment for dynamic responses (order status, stock levels)
- Training phrases: at least 10–15 variants per intent, otherwise confidence will be low on natural speech. We use automatic synonym generation to increase coverage.
Comparison of Dialogflow ES and CX
| Criterion | Dialogflow ES | Dialogflow CX |
|---|---|---|
| Architecture | Linear intent flow | State Machine with pages and transitions |
| Complex scenarios | Hard to maintain | Optimized via built-in State Machine |
| Context | Limited number of turns, manual reset | Explicit transitions, context managed automatically |
| A/B testing | No | Built-in A/B test for routes |
| Versioning | Manual (export/import) | Built-in versions and environments |
| Cost | Free up to limits | Paid, but more efficient for complex bots |
CX outperforms ES for multi-step scenarios by at least 2x in development speed and stability. Budget savings on rewriting—up to 50% with the correct choice from the start.
What Our Work Includes
- Audit of current scenarios and requirements gathering
- Dialogflow version selection (ES or CX) with justification
- Agent design: intents, entities, contexts, flows/pages
- Proxy server development (Node.js/Python) with authentication
- SDK integration into the mobile app (Android Kotlin, iOS Swift)
- Webhook fulfillment setup with your CRM/database
- Testing via Dialogflow Simulator and on real devices
- Maintenance documentation (access, scripts, configs)
- Team training on agent management
Additional Testing Recommendations
Use Dialogflow Simulator to test each intent with different phrasings. Ensure confidence exceeds 0.7 for all target intents. Check error scenario handling.How We Work: Stages
- Analytics — break down scenarios, collect dialogue examples, identify edge cases.
- Design — draw dialogue maps and get client approval.
- Implementation — create the agent, write the proxy, integrate into the client.
- Training and Testing — at least 50 test dialogues per language.
- Deployment — publish to App Store / Google Play, set up monitoring.
Timeline Estimates
- Integration with an existing agent: from 3 to 4 days (including proxy and client setup).
- Development of an agent from scratch for 5–10 scenarios plus mobile client: from 1.5 to 2 weeks.
- Post-launch support: on request, with a one-month warranty for debugging discovered issues.
Contact us for a project evaluation—we'll select the optimal turnkey solution.







