back to docs

Backstories

Learn about the importance of backstories in chatbot development and how they contribute to creating engaging and personalized experiences for users. Discover how multilingual chatbots can benefit from customized backstories and how conversation preempting can set the tone for conversations.

Backstories are an important aspect of chatbots that truly bring them to life. In simple terms, a backstory defines the overall personality and ability of the chatbot.

Think of a backstory as the history of a character. It includes information about the chatbot's experiences, skills, and personality traits. By understanding the backstory, you can understand the chatbot's perspective and what it is trying to convey.

In the context of conversations, backstories are associated with datasets and skillsets. Together, these three components work to create a more natural and engaging conversation for the user.

Backstories can be customized to fit the specific needs of a chatbot. For example, a chatbot designed for customer support might have a backstory that emphasizes patience and empathy. On the other hand, a chatbot designed for entertainment might have a backstory that highlights humor and wit.

Writing Backstories

Backstories serve as natural language programming environments, providing a platform where instructions (i.e. code) can be written and understood in a language similar to our everyday speech. This innovative approach allows for a more intuitive and user-friendly programming experience, as it bridges the gap between complex programming languages and the natural language we use in our daily interactions.

In order to craft a compelling and effective backstory, it is absolutely essential for one to have a thorough understanding of the specific tasks and functions their conversational AI bot is expected to perform. By doing so, they can create dynamic and engaging narratives that not only provide context and depth to their AI bot, but also enhance its utility and efficiency. Therefore, the process of writing a backstory becomes not only a creative endeavor but also a strategic one that directly impacts the functionality of the AI bot.

For those interested in learning the art of writing compelling backstories, we have painstakingly crafted an in-depth tutorial for you. This comprehensive guide will provide you with the tools and techniques needed to create engaging narratives for your conversational AI agents and chatbots. By following our step-by-step approach, you can ensure your characters resonate with your audience and enrich their overall user experience. For a detailed walkthrough, please visit our tutorial here.

Multilingual Chatbots

When it comes to multilingual chatbots, backstories can become even more important. Understanding the cultural nuances and language intricacies of different regions can be difficult, but by crafting a backstory that is specific to a culture or language, chatbots can become more relatable and effective in their conversations. A multilingual chatbot might have different backstories for each language it speaks, allowing it to adapt to the unique needs and expectations of each region.

For example in order to make a chatbot that speaks in French we can define the backstory in french:

Conversation Preempting

Conversation preempting is a notable technique utilized in the design and operation of bots developed using ChatBotKit. This technique serves as a tool to establish and maintain the tone of the conversation, ensuring it adheres to the desired dialogue flow. This aspect can be finely tuned and customized within the backstory of the bot, adding a layer of depth and complexity to the bot's conversational skills. This customization is achieved through the use of conversation scenarios or scenes, a term commonly used within the ChatBotKit community. These scenes allow developers to craft unique and engaging conversation paths, enhancing the user-bot interaction experience.

To create a new scene within your backstory simply use the <|scene|> tag like this:

Multiple scenes can be used to create a more hypothetical scenarios. Here's an example:

In this example, the backstory includes three scenes. When the conversation begins, the chatbot will use one of the scenes at random.

Each scene contains text which will be added to your original backstory. However, you can preempt the conversation using dialogs. Here is an example:

In the example above we preempt the conversation by providing a witty response which the bot will follow and try to imitate for the rest of the conversation.

With scenes and dialogs you can create the perfect chatbot experience.

Skillsets

Although we recommend using dedicated skillsets for greater reusability, skillsets can also be created within your backstories. This approach allows for a seamless integration of specific abilities and functionalities directly into the narrative of your chatbot. The format for defining these skillsets is similar to how you define scenes, making it convenient to incorporate them into your backstory.

By embedding skillsets within backstories, you can create more dynamic and contextually aware chatbots. For instance, if your chatbot needs to handle specific tasks or respond in certain ways based on the storyline, you can define those skillsets right within the backstory itself. This not only enhances the chatbot's performance but also ensures that the responses are consistent with its character and narrative.

To define a skillset within a backstory, you follow a structure akin to scene creation. This makes it easy for developers to expand the bot's capabilities without having to switch contexts or manage multiple resources. Here is an example of how you can integrate a skillset within a backstory:

In summary, while dedicated skillsets offer the advantage of reusability across different chatbots, integrating skillsets within backstories provides a more cohesive and contextually relevant user experience. This dual approach allows developers to choose the best method based on the specific requirements of their chatbot.

Special Fields for Dynamic Substitution

Backstories can be more dynamic and relevant by using special fields that get replaced at runtime. These are placeholders for current date, time, file contents, and other bot backstories. This ensures the chatbot always has up-to-date information during conversations.

Special fields are enclosed in ${} brackets. When the backstory is processed, each field is replaced with its corresponding value.

Here's a table that describes each substitution:

FieldDescription
${EARTH_DATE}Current date in YYYY-MM-DD format, adjusted to user timezone.
${EARTH_TIME}Current time in HH:MM:SS format, adjusted to user timezone.
${ELAPSED_TIME}Elapsed time since the start of the current conversation.
${FILE_<identifier>_CONTENTS}Contents of a file referenced by its ID.
${BOT_<identifier>_BACKSTORY}Backstory of another bot referenced by its ID.

Example: Using Dynamic Fields

Here's an example backstory using dynamic substitution:

When this backstory is used in a conversation, each field is replaced with actual values. For example, if today is June 10, 2026 at 14:30:00:

By using these special fields, you can create backstories that are personalized and always include the most current information relevant to the conversation.

Conclusion

In conclusion, backstories are an essential part of chatbot development that help create a more engaging and personalized experience for the user. By understanding the chatbot's backstory, users can better connect and interact with the chatbot.