Quick Chatbot Simulations

Using Twine and the Trialogue story format, you can build a simple chat simulation in a few hours. I built the sample below in a little less than 2 hours, almost all of which was actually writing the conversation and choices. The story format controls all of the formatting and technical features. Try it yourself to get an idea of what’s possible.

Forced choices, not a true chatbot

If you try the simulation, you’ll see that this isn’t a true chatbot. In a real chatbot, you would type open-ended responses, which would be analyzed by AI. That’s a different level of complexity than this. Instead of programming a true chatbot, this is a chat simulation. Users make choices from a few options. It’s sort of a chatbot, but much easier to build.

Screenshot of forced choices in the chat simulation

Branching scenario structure

Because users make forced choices, this chat is a branching scenario. In total, this scenario has 50 passages in Twine. That took almost 90 minutes to write.

Branching structure of a chat simulation in Twine

This is just a sample so I could see what was possible in a chat simulation, rather than a real project with a client. That means I didn’t have the usual upfront analysis with a SME or planning the scenario I usually do. Some of the choices may not be quite realistic, which I decided was fine for this proof of concept.

Trialogue format

The heavy lifting of making this look like a chat is done via the Trialogue story format. That page includes instructions for installing and using the format. The big difference is that you need to tag each passage with “speaker-NAME.” In this simulation, I tagged most passages “speaker-Anna” (with a few for “speaker-Chat-Info” and the manager, Tom). The choices automatically appear with the name “You.”

Screenshot of a Twine passage with the tag "speaker-Anna"

My one big caution for using Trialogue is that it’s at version 0.0.9 currently. That is, it isn’t at a full 1.0 version yet. It has mostly worked fine for me for this sample, but sometimes it times out and isn’t able to load.

You can see the code for customizing the colors and adding image avatars on the project page.

Alternative: Botscripten

If you have trouble getting Trialogue to load, try the Botscripten format instead. Botscripten is built on Trialogue, so it mostly works the same. Botscripten is designed more for testing and outputting to use in other ways. But, with a little tweaking to the style, you could use Botscripten for a chatbot as well.