Sitecore.BotFramework is released!

Jack Spektor
Chatbots Life
Published in
4 min readSep 19, 2020

--

If you remember in my previous posts I was working on a module that would allow rapid creation of chatbots in Sitecore here:

Good news! It’s now finally released!

Over the last few weeks I was working on refactoring codebase, making it more clean, generic and extendable.

As part of rework I’ve decided to completely abandon Microsoft Bot Framework as a way of storing current chatbot state, and instead storing it in MongoDB.

Unfortunately that meant that now framework would support only Telegram chatbots, however support for other chat platforms could be easily added in the future.

TLDR: Latest version of the framework can be found here:

So whats new?

Updated bot structure and execution logic:

Now bots are defined by states, commands, actions and dialogues

State — defines current conversation position that is unique for each user and changes through whole conversation.

Command — defines user command that is resolved based on the current conversation state.

Actions — defines various business logic that chatbot would execute in response to the user command

Dialogue — encapsulates state, command and actions into single conversation.

Every chatbot starts with start dialogue and its default state. On top of that chatbot also have global state that defines commands that are shared across whole conversation.

Every chat update would result in framework going through commands in current and global state and evaluating whether they match user request based on the command rule.

Trending Bot Articles:

1. 8 Proven Ways to Use Chatbots for Marketing (with Real Examples)

2. How to Use Texthero to Prepare a Text-based Dataset for Your NLP Project

3. 5 Top Tips For Human-Centred Chatbot Design

4. Chatbot Conference Online

The first command that match the rule would be executed.

Framework would then execute ALL actions under the state one by one until the end.

Available actions:

So far following actions are available, though new one could be easily extended (I’ll cover how to do this in the next article)

  • Send message
  • Change current chatbot state
  • Condition — branches actions execution based on the rule
  • Set session variable — stores variable in the user session
  • Set timeout — setups a delayed execution event that could be handled later by the command
  • Set interval — setups regular scheduled event
  • Stop job — stops regular timer
  • Set context item — set current Sitecore item
  • Run dialogue — runs another dialogue

Token resolution

To make our chatbot more configurable and generic I’ve added token resolution to the actions.

Disclaimer — not all actions support this syntax yet. So far its supported only for send message, command rules and setting session variables.

Following tokens would be replaced with their respected values:

@{{text}} — chat update text

@[[sessionVariable]] — replaces token with respected session variable value (if such exists)

@((contextItemFieldName)) — replaces token with respected item field value (if such exists)

New tokens can be easily added by extending “resolveBotTokens” pipeline (will cover extendability of the framework in the next post)

Debugging commands

Chatbots now might be configured to be in debug mode to test their behavior

The following debugging commands are available:

  • /clearsession — deletes Mongo session for the current user
  • /debuginfo — prints current chatbot state and session values
  • /restart — defaults chatbot state to original values

Chatbot output demo:

Aaaand….. happy dance!

Happy dance!

Don’t forget to give us your 👏 !

--

--

Sitecore MVP 2018–2020, Sitecore Developer in AKQA, traveler and lover of life.