def test_botframework_attachments(): from rasa.core.channels.botframework import BotFrameworkInput from copy import deepcopy ch = BotFrameworkInput("app_id", "app_pass") payload = { "type": "message", "id": "123", "channelId": "msteams", "serviceUrl": "https://smba.trafficmanager.net/emea/", "from": { "id": "12:123", "name": "Rasa", "aadObjectId": "123" }, "conversation": { "conversationType": "personal", "tenantId": "123", "id": "a:123", }, "recipient": { "id": "12:123", "name": "Rasa chat" }, } assert ch.add_attachments_to_metadata(payload, None) is None attachments = [{ "contentType": "application/vnd.microsoft.teams.file.download.info", "content": { "downloadUrl": "https://test.sharepoint.com/personal/rasa/123", "uniqueId": "123", "fileType": "csv", }, "contentUrl": "https://test.sharepoint.com/personal/rasa/123", "name": "rasa-test.csv", }] payload["attachments"] = attachments assert ch.add_attachments_to_metadata(payload, None) == { "attachments": attachments } metadata = {"test": 1, "bigger_test": {"key": "value"}} updated_metadata = deepcopy(metadata) updated_metadata.update({"attachments": attachments}) assert ch.add_attachments_to_metadata(payload, metadata) == updated_metadata
def test_botframework_channel(): with mock.patch.object(sanic.Sanic, "run", fake_sanic_run): # START DOC INCLUDE from rasa.core.channels.botframework import BotFrameworkInput from rasa.core.agent import Agent from rasa.core.interpreter import RegexInterpreter # load your trained agent agent = Agent.load(MODEL_PATH, interpreter=RegexInterpreter()) input_channel = BotFrameworkInput( # you get this from your Bot Framework account app_id="MICROSOFT_APP_ID", # also from your Bot Framework account app_password="******", ) s = agent.handle_channels([input_channel], 5004) # END DOC INCLUDE # the above marker marks the end of the code snipped included # in the docs routes_list = utils.list_routes(s) assert routes_list.get("botframework_webhook.health").startswith( "/webhooks/botframework") assert routes_list.get("botframework_webhook.webhook").startswith( "/webhooks/botframework/webhook")
def test_botframework_channel(): # START DOC INCLUDE from rasa.core.channels.botframework import BotFrameworkInput input_channel = BotFrameworkInput( # you get this from your Bot Framework account app_id="MICROSOFT_APP_ID", # also from your Bot Framework account app_password="******", ) s = rasa.core.run.configure_app([input_channel], port=5004) # END DOC INCLUDE # the above marker marks the end of the code snipped included # in the docs routes_list = utils.list_routes(s) assert routes_list["botframework_webhook.health"].startswith( "/webhooks/botframework") assert routes_list["botframework_webhook.webhook"].startswith( "/webhooks/botframework/webhook")