{"id":20003290,"url":"https://github.com/tompaana/bot-message-routing","last_synced_at":"2025-05-04T15:34:53.663Z","repository":{"id":69266882,"uuid":"91082391","full_name":"tompaana/bot-message-routing","owner":"tompaana","description":"Message routing component for chatbots built with Microsoft Bot Framework C# SDK.","archived":false,"fork":false,"pushed_at":"2020-03-13T14:31:04.000Z","size":27719,"stargazers_count":52,"open_issues_count":6,"forks_count":23,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-10T02:52:13.401Z","etag":null,"topics":["azure-storage","bot-framework","chatbots","microsoft-bot-framework"],"latest_commit_sha":null,"homepage":"https://tompaana.github.io/content/chatbots_as_middlemen.html","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tompaana.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-12T10:56:32.000Z","updated_at":"2024-06-14T20:46:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"c8aef9d7-ca30-43f1-80dc-66097ee5af6a","html_url":"https://github.com/tompaana/bot-message-routing","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tompaana%2Fbot-message-routing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tompaana%2Fbot-message-routing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tompaana%2Fbot-message-routing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tompaana%2Fbot-message-routing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tompaana","download_url":"https://codeload.github.com/tompaana/bot-message-routing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224396405,"owners_count":17304149,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure-storage","bot-framework","chatbots","microsoft-bot-framework"],"created_at":"2024-11-13T05:25:01.634Z","updated_at":"2024-11-13T05:25:02.455Z","avatar_url":"https://github.com/tompaana.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Bot Message Routing (component)\n===============================\n\n\u003e **NOTE!**\n\u003e\n\u003e This project is not maintained actively.\n\n[![Build status](https://ci.appveyor.com/api/projects/status/ig99aq8273sx2tyh?svg=true)](https://ci.appveyor.com/project/tompaana/bot-message-routing)\n[![Nuget status](https://img.shields.io/nuget/v/BotMessageRouting.svg)](https://www.nuget.org/packages/BotMessageRouting)\n\nThis project is a message routing component for chatbots built with\n[Microsoft Bot Framework](https://dev.botframework.com/) C# SDK. It enables routing messages between\nusers on different channels. In addition, it can be used in advanced customer service scenarios\nwhere the normal routines are handled by a bot, but in case the need arises, the customer can be\nconnected with a human customer service agent.\n\n**For an example on how to take this code into use, see\n[Intermediator Bot Sample](https://github.com/tompaana/intermediator-bot-sample).**\n\n### Possible use cases ###\n\n* Routing messages between users/bots\n    * See [Chatbots as Middlemen blog post](https://tompaana.github.io/content/chatbots_as_middlemen.html)\n* Customer service scenarios where (in tricky cases) the customer requires a human customer service agent\n    * See [Intermediator Bot Sample](https://github.com/tompaana/intermediator-bot-sample)\n* Keeping track of users the bot interacts with\n* Sending notifications\n    * For more information see [this blog post](https://tompaana.github.io/content/remotely_controlled_bots.html) and\n      [this sample](https://github.com/tompaana/remote-control-bot-sample)\n\nThis is a **.NET Core** project compatible with\n[**Bot Framework v4**](https://github.com/Microsoft/botbuilder-dotnet). The .NET Framework based\nsolution targeting Bot Framework v3.x can be found under releases\n[here](https://github.com/tompaana/bot-message-routing/releases/tag/v1.0.2).\n\nIf you're looking to build your bot using the **Node.js** SDK instead, here's \n[the Node.js/Typescript message routing project](https://github.com/GeekTrainer/botframework-routing).\n\n## Implementation ##\n\n### Terminology ###\n\n| Term | Description |\n| ---- | ----------- |\n| Aggregation (channel) | A channel where the chat requests are sent. The users in the aggregation channel can accept the requests. **Applies only if the aggregation channel based approach is used!** |\n| Connection | Is created when a request is accepted - the acceptor and the requester form a connection (1:1 chat where the bot relays the messages between the users). |\n\nThe [ConversationReference](https://docs.botframework.com/en-us/csharp/builder/sdkreference/d2/d10/class_microsoft_1_1_bot_1_1_connector_1_1_conversation_reference.html)\nclass, provided by the Bot Framework, is used to define the user/bot identities. The instances of\nthe class are managed by the\n[RoutingDataManager](/BotMessageRouting/MessageRouting/DataStore/RoutingDataManager.cs) class.\n\n### Interfaces ###\n\n#### [IRoutingDataStore](/BotMessageRouting/MessageRouting/DataStore/IRoutingDataStore.cs) ####\n\nAn interface for storing the routing data, which includes:\n\n* Users\n* Bot instances\n* Aggregation channels\n* Connection requests\n* Connections\n\nAn implementation of this interface is passed to the constructor of the\n[MessageRouter](/BotMessageRouting/MessageRouting/MessageRouter.cs) class. This solution provides\ntwo implementations of the interface out-of-the-box:\n[InMemoryRoutingDataStore](/BotMessageRouting/MessageRouting/DataStore/InMemory/InMemoryRoutingDataStore.cs)\n(to be used only for testing) and\n[AzureTableRoutingDataStore](/BotMessageRouting/MessageRouting/DataStore/Azure/AzureTableRoutingDataStore.cs).\n  \nThe classes implementing the interface should avoid adding other than storage related sanity checks,\nbecause those are already implemented by the\n[RoutingDataManager](/BotMessageRouting/MessageRouting/DataStore/RoutingDataManager.cs).\n\n#### [ILogger](/BotMessageRouting/MessageRouting/Logging/ILogger.cs) ####\n\nAn interface used by the MessageRouter class to log events and errors.\n\n### Classes ###\n\n#### MessageRouter class ####\n\n**[MessageRouter](/BotMessageRouting/MessageRouting/MessageRouter.cs)** is the main\nclass of the project. It manages the routing data (using the `RoutingDataManager` together with the\nprovided `IRoutingDataStore` implementation) and executes the actual message mediation between the\nconnected users/bots.\n\n##### Properties #####\n\n* [RoutingDataManager](/BotMessageRouting/MessageRouting/DataStore/RoutingDataManager.cs):\n  Provides the main interface for accessing and modifying the routing data (see\n  [IRoutingDataStore documentation](#iroutingdatastore) for more information about the routing data\n  details).\n\n##### Methods #####\n\n* **`CreateSenderConversationReference`** (static): A utility method for creating a\n  `ConversationReference` of the sender in the\n  [`Activity`](https://docs.botframework.com/en-us/csharp/builder/sdkreference/dc/d2f/class_microsoft_1_1_bot_1_1_connector_1_1_activity.html)\n  instance given as an argument.\n* **`CreateRecipientConversationReference`** (static): A utility method for creating a\n  `ConversationReference` of the recipient in the `Activity` instance given as an argument. Note\n  that the recipient is always expected to be a bot.\n* **`SendMessageAsync`**: Sends a message to a specified user/bot.\n* **`StoreConversationReferences`**: A convenient method for storing the sender and the recipient in\n  the `Activity` instance given as an argument. This method is idempotent; the created instances\n  are added only if they are new.\n* **`CreateConnectionRequest`**: Creates a new connection request on behalf of the given user/bot.\n* **`RejectConnectionRequest`**: Removes (rejects) a pending connection request.\n* **`ConnectAsync`**: Establishes a connection between the given users/bots. When successful, this\n  method removes the associated connection request automatically.\n* **`Disconnect`**: Ends the conversation and severs the connection between the users so that the\n  messages are no longer relayed.\n* **`RouteMessageIfSenderIsConnectedAsync`**: Relays the message in the `Activity` instance given as \n  an argument, if the sender is connected with a user/bot.\n\n#### Other classes ####\n\n**[RoutingDataManager](/BotMessageRouting/MessageRouting/DataStore/RoutingDataManager.cs)**\ncontains the main logic for routing data management while leaving the storage specific operation\nimplementations (add, remove, etc.) for the class implementing the `IRoutingDataStore` interface.\nThis is the other main class of the solution and can be accessed via the `MessageRouter` class.\n\n**[AzureTableRoutingDataStore](/BotMessageRouting/MessageRouting/DataStore/Azure/AzureTableRoutingDataStore.cs)**\nimplements the `IRoutingDataStore` interface. The constructor takes the connection string of your\nAzure Table Storage.\n\n**[InMemoryRoutingDataStore](/BotMessageRouting/MessageRouting/DataStore/InMemory/InMemoryRoutingDataStore.cs)**\nimplements the `IRoutingDataStore` interface. Note that this class is meant for testing. **Do not\nuse this class in production!**\n\n**[AbstractMessageRouterResult](/BotMessageRouting/MessageRouting/Results/AbstractMessageRouterResult.cs)**\nis the base class defining the results of the various operations implemented by the `MessageRouter`\nand the `RoutingDataManager` classes. The concrete result classes are:\n\n* [ConnectionRequestResult](/BotMessageRouting/MessageRouting/Results/ConnectionRequestResult.cs)\n* [ConnectionResult](/BotMessageRouting/MessageRouting/Results/ConnectionResult.cs)\n* [MessageRoutingResult](/BotMessageRouting/MessageRouting/Results/MessageRoutingResult.cs)\n* [ModifyRoutingDataResult](/BotMessageRouting/MessageRouting/Results/ModifyRoutingDataResult.cs)\n\nFor classes not mentioned here, see the documentation in the code files.\n\n## Contributing ##\n\nThis is a community project and all contributions are more than welcome!\n\nIf you want to contribute, please consider the following:\n* Use the **development branch** for the base of your changes\n* Remember to update documentation (comments in code)\n* Run the tests to ensure your changes do not break existing functionality\n    * Having an Azure Storage to test is highly recommended\n    * Update/write new tests when needed\n* Pull requests should be first merged into the development branch\n\nPlease do not hesitate to report ideas, bugs etc. under\n[issues](https://github.com/tompaana/bot-message-routing/issues)!\n\n### Acknowledgements ###\n\nSpecial thanks to the contributors (in alphabetical order):\n\n* [Syed Hassaan Ahmed](https://github.com/syedhassaanahmed)\n* [Jorge Cupi](https://github.com/jorgecupi)\n* [Michael Dahl](https://github.com/micdah)\n* [Jamie D](https://github.com/daltskin)\n* [Pedro Dias](https://github.com/digitaldias)\n* [Drazen Dodik](https://twitter.com/diggthedrazen)\n* [Lucas Humenhuk](https://github.com/lcarli)\n* [Lilian Kasem](https://github.com/liliankasem)\n* [Edouard Mathon](https://github.com/edouard-mathon)\n* [Gary Pretty](https://github.com/garypretty)\n* [Jessica Tibaldi](https://github.com/jetiba-ms)\n\nNote that you may not find (all of their) contributions in the change history of this project,\nbecause all of the code including this core functionality used to reside in\n[Intermediator Bot Sample](https://github.com/tompaana/intermediator-bot-sample) project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftompaana%2Fbot-message-routing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftompaana%2Fbot-message-routing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftompaana%2Fbot-message-routing/lists"}