Clustaar & Open Source: Make developers life easy

By Guillaume LebourgeoisFebruary 28, 2019
Clustaar open source make developers life easy

Why open-sourcing?

We decided to open-source several components of our architecture, with 3 goals in mind:

  • to make it as easy as possible to integrate with Clustaar Platform
  • create a community for developers which will help us to improve our open tools
  • bring most freedom as possible in the use of our tools

We are focused on making developers lives as easy as possible when they work with the Clustaar Bot Platform.

clustaar.schemas

This library brings you all the JSON schemas necessary to integrate with the platform, and particularly the different actions available in steps.

As an example, here is a button action schema:

[pastacode lang=”javascript” manual=”BUTTON%20%3D%20Schema(%7B%0A%20%20%20%20%22type%22%3A%20f.Constant(value%3D%22button%22%2C%20read_only%3DTrue)%2C%0A%20%20%20%20%22title%22%3A%20f.String(validators%3Dv.Length(min%3D1%2C%20max%3DBUTTON_TITLE_MAX_LENGTH))%2C%0A%20%20%20%20%22action%22%3A%20f.PolymorphicObject(on%3D%22type%22%2C%20schemas%3DBUTTON_ACTIONS_SCHEMAS)%0A%7D%2C%20name%3D%22button%22)” message=”Button” highlight=”” provider=”manual”/]

It will be very useful to build a webhook, and is used by our clustaar.webhook framework.

clustaar.webhook

Principles

This framework is here to provide all the basics to write a webhook as fast as possible. It is written in Python, and is very light & easy to use.

A webhook enables you to call an external service each time predefined steps are going to be executed. This service will be able to retrieve data from the bot, query internal services, store data, and customize the live bot answers.

Behaviour

The webhook must implement a handler, which will receive meta-data about the current step & user. You will then be able to implement any behavior you desire, then send back the list of actions you’d like the step to execute. It can be sent as it was configured in the bot builder, or you can change it, to include personalization data from your database and more.

The setup of a webhook using the framework is quite straightforward:

[pastacode lang=”python” manual=”from%20clustaar.webhook%20import%20Webhook%2C%20events%0Afrom%20clustaar.schemas.models%20import%20StepReachedResponse%2C%20ConversationSession%0A%0Adef%20handler(request%2C%20response%2C%20notification)%3A%0A%20%20%20%20session%20%3D%20ConversationSession(values%3D%7B%22name%22%3A%20%22John%22%7D)%0A%20%20%20%20return%20StepReachedResponse(actions%3D%5B%5D%2C%20session%3Dsession)%0A%0A%0Aapp%20%3D%20Webhook()%0Aapp.on(events.CONVERSATION_STEP_REACHED%2C%20handler)” message=”Webhook Setup” highlight=”” provider=”manual”/]

Evolution

We use this framework ourselves for custom projects: it is frequently updated and improved by our team 🙂

webchat-components

In some cases, our users don’t want to use the Clustaar Webchat in order to go as far as possible in the integration of the bot: full screen bot, search-bar bot, etc…

This could be painful, as you need to build all the rich content interactions possible with our Clustaar Webchat stream… thankfully, we got you covered 😉 With the webchat-components repository, we provide you with all the necessary graphical components so you can build a visual integration quickly.

Button integration then becomes as fast as writing:

[pastacode lang=”javascript” manual=”%3Cquickreply-console-action%20(onSendReply)%3D%22sendReply(%24event)%22%20(onLoadNextAction)%3D%22loadNextAction()%22%20%5Baction%5D%3D%22action%22%3E%3C%2Fquickreply-console-action%3E” message=”” highlight=”” provider=”manual”/]

Isn’t that cool?

clustaar.authorize

We built an authorization system for our needs! It’s convenient and light, so we decided to share it with you to use it in your own projects.

It integrates very well with Falcon, with a cool @authorize decorator.

[pastacode lang=”python” manual=”class%20ProjectHandler(object)%3A%0A%20%20%20%20%40authorize(view_action)%0A%20%20%20%20def%20on_get(self%2C%20request%2C%20response%2C%20id)%3A%0A%09%20%20%20%20pass” message=”Handler Example” highlight=”” provider=”manual”/]

You can fetch more details from the repository homepage!

Comments welcome

If you have any ideas, suggestions or comments regarding our open-sourced projects, or new project ideas: please get in touch with us!