Implementing Text & Voice UIs

DieProduktMacher
|

19. Juli 2017
|

- min Lesezeit

About the challenges we faced when implementing text and voice interfaces and how we solved them. In this blog post we want to share our development workflow with you: From rapid experimentation to environment variables and automated testing.

Since 2016 we develop chatbots for Facebook Messenger, Slack and others. In addition, we recently published our first Amazon Alexa Skill, bringing Google Analytics to your Amazon Echo. As with any new technology, we first started out with a lot of questions and experimentation to arrive at our own solutions and best practices. While one never finishes this learning journey, we want to share three of our learnings: Rapid experimentation, managing environment variables and automated testing.

Rapid Experimentation

Every Serverless developer knows the flow: code, upload your functions, test your changes, repeat. While deploying Lambda functions doesn't buy you time for a coffee break, these additional seconds surely feel like they could. Thankfully, you can configure Alexa, Facebook and co. to directly talk to your computer. So why not run a local server that always uses your latest code?

At first, we built a custom script that starts a server with expressjs and auto-reloads with nodemon. But with increasing maturity of our projects, it was only natural that our script got more complex every day. Therefore, we decided to write one Serverless plugin that encapsulates all of our scripts. Et voilà, our serverless-local-dev-server was born. The plugin takes Serverless functions with Alexa Skill and HTTP events and runs them as local endpoints. After sharing these endpoints with the internet, you can connect them to services such as Alexa or Facebook.

Managing Environment Variables

Moreover, storing environment variables in our password managers proved to not only be a real headache for teamwork, but also a source of bugs. After improving our workflow for rapid development, we challenged ourselves to enhance this aspect as well. What started with the question "Why can't we synchronise our credentials with the same ease as our code?" ended in lengthy discussions about the optimal solution and resulted in the [serverless-env-generator] plugin. Among others, this plugin allowed us to forget about all the headaches we had with synchronising variables in teams.

Therefore, we store environment variables in one or more YAML files. During deployment the plugin creates a .env file from them, which is loaded when a function is started. In addition, to keep secrets a secret, values can be secured with AWS' Key Management Service (KMS). Furthermore, access to them is limited to deployment privileges. Finally, the plugin takes care of multi-stage configurations and supports custom profiles – an important feature for professional development.

The next challenge: Automated Testing

Currently we are automating our testing of voice and text interfaces. In a first step, we covered the core functionality of our apps with unit tests. Therefore, we built upon the popular chai, mocha & Istanbul combination of testing frameworks. Furthermore we can recommend chai-as-promised to all the Promise-lovers out there.

As a next step, we want to supersede manual testing of conversations and interactions with automated tests. While we view this as a major challenge, we also see opportunities in reducing time to market of our products by eliminating manual tests. So stay tuned for our thoughts and solutions!

What challenges did you face when developing text and voice interfaces?