How I built a chatbot in Swift to create a custom, personalized language learning tool to help me learn Japanese, and why chatbots are a great, practical solution for building useful tools.
Today, I’m here to share some experiences building chat bots, Swift Chat Bots for Fun and Profit. Unfortunately, profit is not guaranteed to be non nil. It’s optional at this point.
Last year there was a lot of media attention on intelligent conversation bots. How many of us have chatted with a chat bot before? Was it a good experience?
This was a chat bot from last year that encouraged users to ask any questions they had about the US presidential election, and you can see, conversational chat bots are still in their early days.
“Who is Hillary Clinton?”
Get more development news like this
“Looking into that…”
With the right design, a bot can still be extremely useful. I found that out when building a language learning bot to help me learn some Japanese vocabulary. It started when I found out that speech bubbles made it easy to select text. You can long tap, and if you turn on iOS’s built-in speech to text accessibility, you can ask Siri to pronounce the selected text and have a pronunciation guide right in your messaging app.
Now I know how to pronounce a phrase, but what does it mean? Every time I send a piece of text, my bot can call Google’s translate API and get an answer for me. For example, “Welcome to Try Swift.”
Picture to Text(2:36)
What if I have a bunch of text and I’m lazy, or what if I’m not sure how to enter the kanji or hiragana? There’s an API for that, too. I can send my bot a photo of any text and connect to Google or Microsoft to do some character recognition for me and return the results. Every other word has a corresponding image that helps me remember the word better. Language geeks use these photos, to get super fast vocabulary gains.
I can take photos of signs I see as I travel and save it to my growing list of words in Japanese; and that connects to Wiktionary. I have a list of words, and every now and then, my bot will choose one and ask me if I remember them. This is called spaced repetition.
Since messaging apps often have watch, phone, and desktop versions, I can quickly review a word in a matter of seconds, even if I’m on the road. The LINE messenger app has a set of default stickers which I can parse as answers.
I can even respond to stickers on my watch. You can design the bot so that if you respond with a thumbs up sticker, it thinks you know the word and it will not add it to the further review queue.
If you reply with the top left “Please, pretty please,” sticker, it will tell you what the word means and add it for more review. That’s the language bot.
What Can We Learn(4:58)
What can we learn from building a bot like this? Messenger apps have a call and response UI, as we saw. It’s limited, but this helps to focus on what functions are truly essential for a bot.
Even with call and response, the types of call and response you can have are surprisingly varied. We’ve seen text, images, buttons, URLs, stickers, and you can also handle sound and location data. It’s not just LINE or Facebook Messenger. Many other apps can also do the same thing.
Keep it simple. Don’t overload your bot with features or it might turn into a complicated command line interface, which is what bots really are. You’ll need afor commands for your bot. Simple can still be powerful and useful.
There are so many APIs these days ready to be built into a convenient function on your phone that you want. In my opinion, what’s good about a bot right now is that bots are a low friction, low commitment service. Don’t try to keep the user engaged. Do your job, do a good job, and let the user go.
There are many resources for building bots . Hosting like Heroku; Vapor seems like the most popular server side Swift framework for now. There are many Messenger APIs, as well, and I strongly encourage everyone to go check them out.
A bot you build for yourself can be an easy way to start a weekend project and to produce something pretty simple but pretty useful, too. Even if you just want to upload files to Dropbox. I want to give a shoutout to a couple of colleagues who worked with me to build a bot to translate menus. The OCR of the language bot actually works in a very similar way to this bot. If you have the LINE messenger app, definitely try it out for yourself and see what the limitations and strengths of this simple bot are. Go and scratch an itch. Write a cool Swift chat bot soon, maybe even this weekend. Thank you.
Have you seen any extensions of bot functionality into virtual reality and augmented reality user interface?
It depends on, whether virtual reality will take off, but if virtual reality does take off, I think intelligent agents will definitely be an important feature in how we interact with that kind of environment. For now, I don’t think we’ll be seeing it very soon, but that’s not my area of expertise. Thank you.