Dialogflow on Rails - Agent import/export & regression testing

Learn how to integrate Dialogflow, a powerful natural language processing tool, into your Rails projects. Discover how to import and export agents, and how to implement regression testing to ensure your agents are working correctly.

Arnaud Lachaume
Arnaud Lachaume LinkedIn
• 3 min read
Dialogflow on Rails - Agent import/export & regression testing

For those that are not familiar with Dialogflow, it’s a platform that makes it easy to design a conversational user interface that can be easily integrated with a variety of applications (e.g. chatbots 😉). Click here for more on Dialogflow.

So you’ve decided to integrate Dialogflow with your Ruby on Rails application. You’ve created a Dialogflow agent, your code is in place, and you’re ready to deploy your application. Before you do, it’s worth considering how active development will be managed.

Ongoing development requires allowing developers to make changes to the agent. Even small changes to the agent could potentially lead to some unexpected behavior which may initially go unnoticed, especially with more complex conversational flows. To mitigate the risk of errors or application downtime, let’s look at how integration/regression testing can be put in place for the agent itself.

Agent Upload/Download

The following rake task examples can be adapted and used to upload & download the agent as a zip file. We’ll need this to write the regression tests and it also makes it easy to record the state of the agent or reset the agent to a previous state during development.

The rake tasks above make use of the following utility class to assist with zip file manipulation.

Regression Testing

Now that the agent push/pull rake tasks are in place, they can be used to write regression tests.

Here is an example of how they can be set up:

The example above assumes the existence of a directory of JSON files containing testing scenarios. Here is a basic example of how one of these files might look if we wanted to test the behavior of Dialogflow’s prebuilt smalltalk agent, and an example of a more complex scenario with parameter expectations:

Recap

Dialogflow makes it easy to add powerful conversational capabilities to your application. But, with something as complex as natural language processing, integration/regression testing can help you save time, avoid frustration, and make your Dialogflow integration as robust as possible.

I hope the suggestions and examples in this article help you to simplify your development as much as they’ve helped me.

About us

Keypup's SaaS solution allows engineering teams and all software development stakeholders to gain a better understanding of their engineering efforts by combining real-time insights from their development and project management platforms. The solution integrates multiple data sources into a unified database along with a user-friendly dashboard and insights builder interface. Keypup users can customize tried-and-true templates or create their own reports, insights and dashboards to get a full picture of their development operations at a glance, tailored to their specific needs.


Code snippets hosted with ❤ by GitHub.

Banner imagine designed by Designed by zaie / Freepik

‍

Ready to Transform Your Analytics?

Join teams already using AI to make data-driven decisions faster than ever.

Most Recent Articles

The Due Date Mirage: Why Half of Your Jira Deadlines Slip, and Where the Late Days Go

The Due Date Mirage: Why Half of Your Jira Deadlines Slip, and Where the Late Days Go

Engineering leaders on Reddit keep asking the same question: why do we miss so many dates when every team says the work is on track? In a typical enterprise organization, 46% of Jira issues with a due date close late, and only 41% of the misses come from code taking too long. Learn how Keypup MCP splits every missed due date into waiting, coding, review and closing time, using Jira due dates, workflow history, story points and linked pull requests.

Stephane Ibos
The Thin Ticket Tax: How Underspecified Jira Issues Double Your Cycle Time

The Thin Ticket Tax: How Underspecified Jira Issues Double Your Cycle Time

Engineers on Reddit keep saying the same thing: the ticket said "fix the export" and nothing else. In a typical enterprise organization, 38% of completed Jira issues have an empty or one-line description, and once started they take twice as long, bounce back to In Progress 3.5 times as often and get changes requested in review twice as often. Learn how Keypup MCP measures ticket quality from issue descriptions, workflow history, sprints, comments and linked pull requests.

Arnaud Lachaume
The Untraceable Merge: When a Third of Your Merged Code Has No Ticket Behind It

The Untraceable Merge: When a Third of Your Merged Code Has No Ticket Behind It

Enterprise change policies say every change traces back to a ticket, but in a typical organization 34% of merged pull requests resolve no Jira issue, carrying 29% of the code. Learn what engineering leaders on Reddit say about pull requests without linked issues, audit traceability and R&D capitalization, and how Keypup MCP measures the traceability gap from resolved issues, branch names, issue types, approvals and mergers.

Thomas Williams