| Developers Guide

| Developers Guide

  • Docs
  • API
  • Help
  • Blog

›Tutorials

Notes on Versions Released

  • Migrating & Updating
  • Updating to New Releases

Getting Started

  • Introduction
  • Installation
  • Quick Start

Main Concepts

  • Overview
  • Glossary
  • CMS
  • Dialog Engine
  • Actions & Hooks
  • Memory
  • Modules
  • NLU
  • Emulator

Advanced Guides

  • Debug
  • Configuration
  • Authentication Methods
  • Custom Module
  • Performances
  • Hosting
  • Version Control
  • Development Pipelines
  • Clustering

Channels

  • Website Embedding
  • Facebook Messenger
  • Telegram
  • Microsoft Teams
  • Converse API
  • Slack
  • Smooch (Sunshine Conversations)
  • FAQ

Tutorials

  • Deploying a cluster on Digital Ocean
  • How to act on an intent
  • Acting Proactively
  • Using Carousel Postback
  • How to use Slot Skill
  • How to use Call API Skill
  • Calling an API in a Custom Action
  • Shortlinks
  • Connecting your bot with your existing backend
  • Supported databases
  • Timeouts
  • Human in the loop
  • Jump To
  • Inter-bot Communication / Delegation
  • Contextual FAQ
  • Authenticate a user against a 3rd Party OAuth
  • Listening for file changes
  • Using a 3rd party NLU
  • Using the UiPath integration for Botpress

Pro Edition

  • About
  • Licensing
  • Configuring RBAC
  • Monitoring & Alerting
  • Bot Pipelines
  • Internationalization

Inter-bot Communication / Delegation

Overview

In this tutorial, you will learn how a chatbot could "delegate" questions or tasks to other bots. We call this concept "inter-bot" communication.

The code for this example is available in the examples directory of our GitHub repository (update workspaces.json with the three bots if you copied them).

Example

Structure

Diagram

Step 1 – Creating the bots

The first thing you will need to do is create three bots: one "master" bot (the one that will delegate questions to other bots), and two "slave" bots (the ones who get asked questions by the master).

Head to the admin interface and create three bots names master, sub1 and sub2 respectively, all based on the "empty bot" template.

  • Leave master bot empty for now.
  • In the sub1 bot, create some QnA entries that are related to the same domain (pick the default global category/context).
  • In the sub2 bot, do the same thing for another domain.

For example, sub1 could answer questions about Human Resources, while sub2 could answer questions related to IT Operations.

At this point, you should have three bots. Master doesn't do anything, while sub1 and sub2 can answer questions about HR and IT Operations respectively when you talk to them individually.

Step 2 – Delegation Action (master bot)

Now let's see how you can make the Master bot ask the questions to the slave bots. To do this, we are going to create an action called delegate_to_bots inside the master bot.

The action you need to create can be found here. Just copy and paste this file in your <data>/bots/master/actions directory.

Next, you will need to create a flow that make use of that action. For the sake of simplicity of this tutorial, all the master bot will be able to do is delegate anything you tell him to the slave bots. Of course you could call the action at any time and even adapt the delegate_to_bots action to pass in more contexts etc.

In the main.flow.json flow of your master bot, recreate the structure below.

Flow

The content of the text element is the following:

The bot {{temp.delegation.0.botId}} can help you with that question.

[Talk to {{temp.delegation.0.botId}}]({{{temp.delegation.0.botUrl}}})

By the way, {{temp.delegation.0.botId}} is telling you:
> {{{temp.delegation.0.answer}}}

Tip: The reason we use triple mustaches ({{{ ... }}}) is to prevent Botpress from escaping the special characters found in the variables.

Conclusion

That's it! You now have the basic structure in place to allow inter-bot collaboration.

← Jump ToContextual FAQ →
  • Overview
  • Structure
  • Step 1 – Creating the bots
  • Step 2 – Delegation Action (master bot)
  • Conclusion
| Developers Guide
Docs
Getting Started (or other categories)Guides (or other categories)API Reference (or other categories)
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHubStar
Facebook Open Source
Copyright © 2021 Botpress Inc.