Sitecore Bot Framework Part 2: Adding multi-site functionality and more features!

Jack Spektor
Chatbots Life
Published in
4 min readMar 25, 2019

--

Hello, this is a continuation of my previous story on integrating Microsoft Bot Framework and Sitecore.

If you missed it — take a look here:

This time I’m going to cover new features that were added to the framework.

Multisite support

Our previous version of chatbot was limited in a way that it could have only one chatbot instance running on a single Sitecore instance.

Sitecore, however, supports multisite functionality, which means that you can have huge numbers of sites running simultaneously on Sitecore.

To achieve this I’m going to create a custom controller factory that will resolve a new instance of BotController for each chatbot hosted in Sitecore.

Top 4 Bot Tutorials

1. Build simple ChatBot in Python with RASA — Part 1

2. Build a simple ChatBot in Python with RASA — Part 2

3. How I developed my own ‘learning’ chatbot in Python

4. Chatbot Conference 2019 in NYC

Each chatbot will be resolved by its hostname and route id that is defined in Sitecore.

Our test chatbot is defined under the “Sandbox” site in Sitecore and configured with “sandbox” route id.

For example our test chatbot is hosted under “testing92.sc” hostname and defined by “sandbox” id, so when testing in emulator it should be referenced as “http://testing92.sc:9999/sitecore/bot/sandbox”.

We can define multiple numbers of chatbots per site now just by creating new chatbot items in Sitecore!

Branching

The end goal of building our Sitecore Bot Framework is to be able to build a chatbot without a single line of code. All is required is to build up content from Sitecore instance.

For this being able to branch execution based on user input is crucial.

For this we are going to introduce new Sitecore template — “DecisionBranch”.

This item would be available to be added from any Action item and will contain actions that would be executed if such execution branch would be selected.

To define the rules for branch selection we’ll use our beloved Sitecore Rules Engine.

Here is the example — in one of the “Prompt” bot actions we’d define the rule that would select which branch should be executed depending on the user input.

Now we can build more complicated bots just by defining rules and Sitecore content without having a single line of code.

Extensibility

The cool thing about Sitecore is that you can replace or extend almost any part of Sitecore in configuration.

I’m going to follow this in Sitecore Bot Framework.

For this I’m going to define all the bot actions mappings as part of configuration.

All action classes should implement either IMessageDialogAction or IPromptDialogAction depending if its a prompt action that requires user input or a general chatbot message.

Now we can extend the framework just by applying Sitecore patch config without the need to rewrite code.

Our framework rules also could be easily extended since they are defined in “/sitecore/system/Settings/Rules/Definitions/Elements/SitecoreBotFramework” with Sitecore Rules Engine configuration.

Sitecore Bot Framework conditions and actions for Sitecore rules engine.

Welcome message

We’d like to display helpful message to each new user that will introduce them to chatbot.

This is simple, but very useful feature that we’d like to have in our bots.

Of course it would be content-editable from Sitecore.

There is a great guide how-to achieve this from Microsoft Bot Framework here.

Whats next?

Our chatbots are growing!

Next time I’m going to introduce more features (cards, select options, authentication, goal conditions, etc.) and also going to run the chatbot in Azure on a real website using “Microsoft Bot Framework Webchat”.

Stay in touch!

Don’t forget to give us your 👏 !

--

--

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