forked from mindsdb/mindsdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ramvzz/feature/webhook_based_chatbot
Chat-bot Support for Webhooks (MS Bot Framework-based MS Teams Chat-bot)
- Loading branch information
Showing
15 changed files
with
333 additions
and
1,414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from flask_restx import Namespace | ||
|
||
ns_conf = Namespace('webhooks', description='API to receive messages from bots') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from flask import request | ||
from flask_restx import Resource | ||
|
||
from mindsdb.api.http.namespaces.configs.webhooks import ns_conf | ||
from mindsdb.interfaces.chatbot.chatbot_controller import ChatBotController | ||
from mindsdb.metrics.metrics import api_endpoint_metrics | ||
|
||
|
||
# Stores the memory of the various chat-bots mapped by their webhook tokens. | ||
# This is required because each time a new request is made, a new instance of the ChatBotTask is created. | ||
# This causes the memory to be lost. | ||
chat_bot_memory = {} | ||
|
||
|
||
@ns_conf.route('/chatbots/<webhook_token>') | ||
class ChatbotWebhooks(Resource): | ||
@ns_conf.doc('chatbots_webhook') | ||
@api_endpoint_metrics('POST', '/webhooks/chatbots/<webhook_token>') | ||
def post(self, webhook_token: str) -> None: | ||
""" | ||
This endpoint is used to receive messages posted by bots from different platforms. | ||
Args: | ||
webhook_token (str): The token of the webhook. It is used to uniquely identify the webhook. | ||
""" | ||
request_data = request.json | ||
|
||
chat_bot_controller = ChatBotController() | ||
return chat_bot_controller.on_webhook(webhook_token, request_data, chat_bot_memory) |
318 changes: 0 additions & 318 deletions
318
mindsdb/integrations/handlers/ms_teams_handler/ms_graph_api_teams_client.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.