├── libraries ├── botbuilder-ai │ ├── tests │ │ ├── __init__.py │ │ ├── qna │ │ │ └── test_data │ │ │ │ ├── NoAnswerFoundInKb.json │ │ │ │ ├── ReturnsAnswer.json │ │ │ │ ├── AnswerWithHighScoreProvidedContext.json │ │ │ │ ├── AnswerWithPrompts.json │ │ │ │ ├── AnswerWithLowScoreProvidedWithoutContext.json │ │ │ │ ├── AnswerWithOptions.json │ │ │ │ └── TopNAnswer.json │ │ └── luis │ │ │ ├── test_data │ │ │ ├── V1DatetimeResolution.json │ │ │ ├── TraceActivity.json │ │ │ ├── SingleIntent_SimplyEntity.json │ │ │ ├── MultipleIntents_ListEntityWithSingleValue.json │ │ │ ├── MultipleIntents_ListEntityWithMultiValues.json │ │ │ ├── MultipleIntents_PrebuiltEntity.json │ │ │ ├── MultipleIntents_PrebuiltEntitiesWithMultiValues.json │ │ │ └── MultipleIntents_CompositeEntityModel.json │ │ │ ├── null_adapter.py │ │ │ ├── telemetry_override_recognizer.py │ │ │ └── override_fill_recognizer.py │ ├── requirements.txt │ ├── botbuilder │ │ └── ai │ │ │ ├── __init__.py │ │ │ ├── luis │ │ │ ├── __init__.py │ │ │ ├── luis_telemetry_constants.py │ │ │ └── luis_prediction_options.py │ │ │ ├── about.py │ │ │ └── qna │ │ │ ├── qnamaker_endpoint.py │ │ │ ├── models │ │ │ ├── feedback_records.py │ │ │ ├── metadata.py │ │ │ ├── train_request_body.py │ │ │ ├── feedback_record.py │ │ │ ├── query_results.py │ │ │ ├── qna_request_context.py │ │ │ ├── qna_response_context.py │ │ │ ├── __init__.py │ │ │ └── prompt.py │ │ │ ├── qnamaker_options.py │ │ │ ├── utils │ │ │ ├── __init__.py │ │ │ └── qna_telemetry_constants.py │ │ │ ├── qnamaker_telemetry_client.py │ │ │ └── __init__.py │ └── run_test.cmd ├── botbuilder-applicationinsights │ ├── tests │ │ └── __init__.py │ ├── django_tests │ │ ├── .gitignore │ │ ├── template.html │ │ ├── urls.py │ │ ├── run_test.sh │ │ ├── README.md │ │ └── all_tests.sh │ ├── setup.cfg │ ├── botbuilder │ │ └── applicationinsights │ │ │ ├── processor │ │ │ └── __init__.py │ │ │ ├── flask │ │ │ ├── __init__.py │ │ │ └── flask_telemetry_processor.py │ │ │ ├── about.py │ │ │ ├── __init__.py │ │ │ ├── django │ │ │ ├── __init__.py │ │ │ └── django_telemetry_processor.py │ │ │ └── bot_telemetry_processor.py │ └── requirements.txt ├── botbuilder-schema │ ├── requirements.txt │ ├── setup.cfg │ ├── MANIFEST.in │ └── setup.py ├── swagger │ ├── .gitignore │ ├── package.json │ ├── tokenAPI.md │ └── README.md ├── botbuilder-azure │ ├── setup.cfg │ ├── .cache │ │ └── v │ │ │ └── cache │ │ │ └── lastfailed │ └── botbuilder │ │ └── azure │ │ ├── about.py │ │ └── __init__.py ├── botbuilder-core │ ├── setup.cfg │ ├── tests │ │ ├── requirements.txt │ │ ├── call_counting_middleware.py │ │ ├── test_utilities.py │ │ └── test_message.py │ ├── requirements.txt │ └── botbuilder │ │ └── core │ │ ├── state_property_info.py │ │ ├── property_manager.py │ │ ├── recognizer.py │ │ ├── adapters │ │ └── __init__.py │ │ ├── inspection │ │ ├── inspection_state.py │ │ ├── __init__.py │ │ ├── inspection_sessions_by_status.py │ │ └── inspection_session.py │ │ ├── about.py │ │ ├── intent_score.py │ │ ├── conversation_reference_extension.py │ │ ├── telemetry_logger_constants.py │ │ ├── invoke_response.py │ │ ├── telemetry_constants.py │ │ ├── bot_state_set.py │ │ ├── auto_save_state_middleware.py │ │ ├── state_property_accessor.py │ │ ├── conversation_state.py │ │ └── private_conversation_state.py ├── botbuilder-dialogs │ ├── setup.cfg │ ├── botbuilder │ │ └── dialogs │ │ │ ├── prompts │ │ │ ├── prompt_validator.py │ │ │ ├── datetime_resolution.py │ │ │ ├── prompt_recognizer_result.py │ │ │ ├── prompt_options.py │ │ │ ├── oauth_prompt_settings.py │ │ │ └── __init__.py │ │ │ ├── waterfall_step.py │ │ │ ├── choices │ │ │ ├── list_style.py │ │ │ ├── choice.py │ │ │ ├── sorted_value.py │ │ │ ├── found_value.py │ │ │ ├── token.py │ │ │ ├── find_choices_options.py │ │ │ ├── found_choice.py │ │ │ ├── model_result.py │ │ │ ├── __init__.py │ │ │ └── choice_factory_options.py │ │ │ ├── dialog_turn_result.py │ │ │ ├── about.py │ │ │ ├── dialog_turn_status.py │ │ │ ├── dialog_instance.py │ │ │ ├── dialog_state.py │ │ │ └── dialog_reason.py │ ├── requirements.txt │ └── tests │ │ ├── test_dialog_set.py │ │ ├── choices │ │ ├── test_choice.py │ │ └── test_choice_factory_options.py │ │ └── test_prompt_validator_context.py ├── botframework-connector │ ├── setup.cfg │ ├── MANIFEST.in │ ├── botframework │ │ └── connector │ │ │ ├── async_mixin │ │ │ └── __init__.py │ │ │ ├── auth │ │ │ ├── verify_options.py │ │ │ ├── claims_identity.py │ │ │ ├── __init__.py │ │ │ ├── constants.py │ │ │ ├── endorsements_validator.py │ │ │ └── government_constants.py │ │ │ ├── version.py │ │ │ ├── token_api │ │ │ ├── version.py │ │ │ ├── aio │ │ │ │ ├── __init__.py │ │ │ │ └── operations_async │ │ │ │ │ └── __init__.py │ │ │ ├── operations │ │ │ │ └── __init__.py │ │ │ ├── __init__.py │ │ │ └── models │ │ │ │ └── __init__.py │ │ │ ├── models │ │ │ └── __init__.py │ │ │ ├── aio │ │ │ ├── __init__.py │ │ │ └── operations_async │ │ │ │ └── __init__.py │ │ │ ├── operations │ │ │ └── __init__.py │ │ │ ├── __init__.py │ │ │ ├── emulator_api_client.py │ │ │ └── channels.py │ ├── tests │ │ ├── requirements.txt │ │ ├── resources │ │ │ ├── bot.png │ │ │ └── bot_icon.png │ │ ├── authentication_stub.py │ │ ├── recordings │ │ │ ├── test_attachments_get_attachment_view_with_invalid_attachment_id_fails.yaml │ │ │ ├── test_attachments_get_info_invalid_attachment_id_fails.yaml │ │ │ ├── test_conversations_get_conversation_members_invalid_id_fails.yaml │ │ │ ├── test_conversations_delete_activity_with_invalid_conversation_id_fails.yaml │ │ │ ├── test_conversations_get_conversation_members.yaml │ │ │ ├── test_conversations_send_to_conversation.yaml │ │ │ ├── test_conversations_create_conversation_without_members_fails.yaml │ │ │ ├── test_conversations_send_to_conversation_with_invalid_conversation_id_fails.yaml │ │ │ ├── test_conversations_create_conversation.yaml │ │ │ ├── test_conversations_reply_to_activity_with_invalid_conversation_id_fails.yaml │ │ │ └── test_conversations_create_conversation_with_invalid_bot_id_fails.yaml │ │ └── test_endorsements_validator.py │ └── requirements.txt └── botbuilder-testing │ ├── requirements.txt │ └── botbuilder │ └── testing │ ├── __init__.py │ └── about.py ├── samples ├── python_django │ └── 13.core-bot │ │ ├── db.sqlite3 │ │ ├── helpers │ │ ├── __init__.py │ │ ├── dialog_helper.py │ │ └── activity_helper.py │ │ ├── requirements.txt │ │ ├── bots │ │ ├── __init__.py │ │ ├── urls.py │ │ ├── wsgi.py │ │ └── resources │ │ │ └── welcomeCard.json │ │ ├── dialogs │ │ └── __init__.py │ │ ├── booking_details.py │ │ ├── config.py │ │ └── manage.py ├── 45.state-management │ ├── requirements.txt │ ├── bots │ │ └── __init__.py │ ├── data_models │ │ ├── user_profile.py │ │ ├── __init__.py │ │ └── conversation_data.py │ └── config.py ├── 06.using-cards │ ├── requirements.txt │ ├── dialogs │ │ ├── __init__.py │ │ └── resources │ │ │ └── __init__.py │ ├── bots │ │ ├── __init__.py │ │ └── rich_cards_bot.py │ ├── helpers │ │ ├── __init__.py │ │ ├── dialog_helper.py │ │ └── activity_helper.py │ └── config.py ├── experimental │ └── 101.corebot-bert-bidaf │ │ ├── model │ │ └── model_corebot101 │ │ │ ├── bidaf │ │ │ ├── requirements.txt │ │ │ └── model_runtime │ │ │ │ └── __init__.py │ │ │ ├── bert │ │ │ ├── requirements.txt │ │ │ ├── model_runtime │ │ │ │ └── __init__.py │ │ │ ├── common │ │ │ │ ├── __init__.py │ │ │ │ ├── input_features.py │ │ │ │ └── input_example.py │ │ │ └── train │ │ │ │ └── __init__.py │ │ │ ├── about.py │ │ │ └── booking_details.py │ │ ├── model_runtime_svc │ │ ├── model_runtime_svc_corebot101 │ │ │ ├── handlers │ │ │ │ └── __init__.py │ │ │ ├── __init__.py │ │ │ ├── about.py │ │ │ └── docker_init.py │ │ └── setup.py │ │ ├── media │ │ ├── jupyter_lab_bert_train.PNG │ │ ├── jupyter_lab_model_nav.PNG │ │ ├── jupyter_lab_bert_complete.PNG │ │ ├── jupyter_lab_bert_runtime.PNG │ │ ├── jupyter_lab_bidaf_runtime.PNG │ │ ├── jupyter_lab_run_all_cells.PNG │ │ └── jupyter_lab_select_kernel.PNG │ │ ├── bot │ │ ├── helpers │ │ │ ├── __init__.py │ │ │ ├── dialog_helper.py │ │ │ └── activity_helper.py │ │ ├── bots │ │ │ └── __init__.py │ │ ├── dialogs │ │ │ └── __init__.py │ │ ├── config.py │ │ └── requirements.txt │ │ ├── docker │ │ └── docker-compose.yml │ │ ├── NOTICE.md │ │ ├── Dockerfile_bot │ │ ├── requirements.txt │ │ └── Dockerfile_model_runtime ├── 01.console-echo │ ├── requirements.txt │ ├── adapter │ │ └── __init__.py │ ├── bot.py │ └── main.py ├── 13.core-bot │ ├── requirements.txt │ ├── helpers │ │ ├── __init__.py │ │ ├── dialog_helper.py │ │ └── activity_helper.py │ ├── bots │ │ └── __init__.py │ ├── dialogs │ │ └── __init__.py │ ├── booking_details.py │ ├── config.py │ ├── flight_booking_recognizer.py │ └── cards │ │ └── welcomeCard.json ├── 21.corebot-app-insights │ ├── helpers │ │ ├── __init__.py │ │ ├── dialog_helper.py │ │ └── activity_helper.py │ ├── bots │ │ └── __init__.py │ ├── requirements.txt │ ├── dialogs │ │ └── __init__.py │ ├── booking_details.py │ ├── NOTICE.md │ └── config.py └── README.md ├── Generator └── generator-botbuilder-python │ ├── .gitattributes │ ├── .gitignore │ ├── .eslintignore │ ├── generators │ └── app │ │ └── templates │ │ ├── requirements.txt │ │ └── README.md │ ├── .travis.yml │ ├── .yo-rc.json │ ├── .editorconfig │ ├── __tests__ │ └── app.js │ └── LICENSE ├── .coveragerc ├── doc ├── media │ └── FrameWorkPython.png └── README.md ├── .pre-commit-config.yaml ├── .cache └── v │ └── cache │ └── lastfailed ├── .github └── ISSUE_TEMPLATE │ ├── python-sdk-question.md │ ├── python-sdk-feature-request.md │ └── python-sdk-bug.md ├── .gitignore └── LICENSE /libraries/botbuilder-ai/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /samples/python_django/13.core-bot/db.sqlite3: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libraries/botbuilder-schema/requirements.txt: -------------------------------------------------------------------------------- 1 | msrest>=0.6.6 -------------------------------------------------------------------------------- /libraries/swagger/.gitignore: -------------------------------------------------------------------------------- 1 | generated 2 | node_modules/ -------------------------------------------------------------------------------- /Generator/generator-botbuilder-python/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /libraries/botbuilder-azure/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=0 -------------------------------------------------------------------------------- /libraries/botbuilder-core/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=0 -------------------------------------------------------------------------------- /libraries/botbuilder-core/tests/requirements.txt: -------------------------------------------------------------------------------- 1 | requests_mock>=1.7.0 -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=0 -------------------------------------------------------------------------------- /libraries/botbuilder-schema/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=1 -------------------------------------------------------------------------------- /samples/45.state-management/requirements.txt: -------------------------------------------------------------------------------- 1 | botbuilder-core>=4.4.0b1 -------------------------------------------------------------------------------- /libraries/botframework-connector/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=1 -------------------------------------------------------------------------------- /Generator/generator-botbuilder-python/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/django_tests/.gitignore: -------------------------------------------------------------------------------- 1 | aitest 2 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/prompt_validator.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Generator/generator-botbuilder-python/.eslintignore: -------------------------------------------------------------------------------- 1 | coverage 2 | **/templates 3 | -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=0 -------------------------------------------------------------------------------- /libraries/botbuilder-schema/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include *.rst 2 | include azure_bdist_wheel.py -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/botbuilder/applicationinsights/processor/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libraries/botframework-connector/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include *.rst 2 | include azure_bdist_wheel.py -------------------------------------------------------------------------------- /samples/06.using-cards/requirements.txt: -------------------------------------------------------------------------------- 1 | botbuilder-core>=4.4.0b1 2 | botbuilder-dialogs>=4.4.0b1 -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/django_tests/template.html: -------------------------------------------------------------------------------- 1 | Test django template: {{ context }} -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | source = ./libraries/ 3 | omit = 4 | */tests/* 5 | setup.py 6 | */botbuilder-schema/* -------------------------------------------------------------------------------- /doc/media/FrameWorkPython.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baruchiro/botbuilder-python/master/doc/media/FrameWorkPython.png -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/requirements.txt: -------------------------------------------------------------------------------- 1 | msrest>=0.6.6 2 | botbuilder-core>=4.4.0b1 3 | aiounittest>=1.1.0 -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model/model_corebot101/bidaf/requirements.txt: -------------------------------------------------------------------------------- 1 | nltk 2 | numpy 3 | onnxruntime 4 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/async_mixin/__init__.py: -------------------------------------------------------------------------------- 1 | from .async_mixin import AsyncServiceClientMixin 2 | -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/requirements.txt: -------------------------------------------------------------------------------- 1 | pytest-cov>=2.6.0 2 | pytest>=4.3.0 3 | azure-devtools>=0.4.1 4 | pytest-asyncio -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model/model_corebot101/bert/requirements.txt: -------------------------------------------------------------------------------- 1 | torch 2 | tqdm 3 | pytorch-pretrained-bert 4 | -------------------------------------------------------------------------------- /samples/01.console-echo/requirements.txt: -------------------------------------------------------------------------------- 1 | asyncio>=3.4.3 2 | botbuilder-core>=4.4.0.b1 3 | botbuilder-schema>=4.4.0.b1 4 | botframework-connector>=4.4.0.b1 -------------------------------------------------------------------------------- /samples/13.core-bot/requirements.txt: -------------------------------------------------------------------------------- 1 | botbuilder-dialogs>=4.4.0.b1 2 | botbuilder-ai>=4.4.0.b1 3 | datatypes-date-time>=1.0.0.a2 4 | flask>=1.0.3 5 | 6 | -------------------------------------------------------------------------------- /libraries/botbuilder-testing/requirements.txt: -------------------------------------------------------------------------------- 1 | botbuilder-schema>=4.4.0b1 2 | botbuilder-core>=4.4.0b1 3 | botbuilder-dialogs>=4.4.0b1 4 | aiounittest>=1.1.0 5 | -------------------------------------------------------------------------------- /libraries/botframework-connector/requirements.txt: -------------------------------------------------------------------------------- 1 | msrest>=0.6.6 2 | botbuilder-schema>=4.4.0b1 3 | requests>=2.18.1 4 | PyJWT==1.5.3 5 | cryptography==2.1.4 -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/resources/bot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baruchiro/botbuilder-python/master/libraries/botframework-connector/tests/resources/bot.png -------------------------------------------------------------------------------- /Generator/generator-botbuilder-python/generators/app/templates/requirements.txt: -------------------------------------------------------------------------------- 1 | git+https://github.com/Azure/msrest-for-python@async2 2 | botbuilder-core>=4.4.0b1 3 | aiohttp>=3.0.0 -------------------------------------------------------------------------------- /Generator/generator-botbuilder-python/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - v10 4 | - v8 5 | - v6 6 | - v4 7 | after_script: cat ./coverage/lcov.info | coveralls 8 | -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/resources/bot_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baruchiro/botbuilder-python/master/libraries/botframework-connector/tests/resources/bot_icon.png -------------------------------------------------------------------------------- /libraries/botbuilder-ai/requirements.txt: -------------------------------------------------------------------------------- 1 | msrest>=0.6.6 2 | botbuilder-schema>=4.4.0b1 3 | botbuilder-core>=4.4.0b1 4 | requests>=2.18.1 5 | aiounittest>=1.1.0 6 | azure-cognitiveservices-language-luis>=0.2.0 -------------------------------------------------------------------------------- /libraries/botbuilder-core/requirements.txt: -------------------------------------------------------------------------------- 1 | msrest>=0.6.6 2 | botframework-connector>=4.4.0b1 3 | botbuilder-schema>=4.4.0b1 4 | requests>=2.18.1 5 | PyJWT==1.5.3 6 | cryptography==2.1.4 7 | aiounittest>=1.2.1 -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model_runtime_svc/model_runtime_svc_corebot101/handlers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/media/jupyter_lab_bert_train.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baruchiro/botbuilder-python/master/samples/experimental/101.corebot-bert-bidaf/media/jupyter_lab_bert_train.PNG -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/media/jupyter_lab_model_nav.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baruchiro/botbuilder-python/master/samples/experimental/101.corebot-bert-bidaf/media/jupyter_lab_model_nav.PNG -------------------------------------------------------------------------------- /samples/06.using-cards/dialogs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .main_dialog import MainDialog 5 | 6 | __all__ = ["MainDialog"] 7 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/media/jupyter_lab_bert_complete.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baruchiro/botbuilder-python/master/samples/experimental/101.corebot-bert-bidaf/media/jupyter_lab_bert_complete.PNG -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/media/jupyter_lab_bert_runtime.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baruchiro/botbuilder-python/master/samples/experimental/101.corebot-bert-bidaf/media/jupyter_lab_bert_runtime.PNG -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/media/jupyter_lab_bidaf_runtime.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baruchiro/botbuilder-python/master/samples/experimental/101.corebot-bert-bidaf/media/jupyter_lab_bidaf_runtime.PNG -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/media/jupyter_lab_run_all_cells.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baruchiro/botbuilder-python/master/samples/experimental/101.corebot-bert-bidaf/media/jupyter_lab_run_all_cells.PNG -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/media/jupyter_lab_select_kernel.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baruchiro/botbuilder-python/master/samples/experimental/101.corebot-bert-bidaf/media/jupyter_lab_select_kernel.PNG -------------------------------------------------------------------------------- /samples/06.using-cards/bots/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .rich_cards_bot import RichCardsBot 5 | 6 | __all__ = ["RichCardsBot"] 7 | -------------------------------------------------------------------------------- /samples/01.console-echo/adapter/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .console_adapter import ConsoleAdapter 5 | 6 | __all__ = ["ConsoleAdapter"] 7 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/requirements.txt: -------------------------------------------------------------------------------- 1 | msrest>=0.6.6 2 | botframework-connector>=4.4.0b1 3 | botbuilder-schema>=4.4.0b1 4 | botbuilder-core>=4.4.0b1 5 | requests>=2.18.1 6 | PyJWT==1.5.3 7 | cryptography==2.1.4 8 | aiounittest>=1.1.0 -------------------------------------------------------------------------------- /Generator/generator-botbuilder-python/.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-node": { 3 | "promptValues": { 4 | "authorName": "Microsoft", 5 | "authorEmail": "botframework@microsoft.com", 6 | "authorUrl": "" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /samples/06.using-cards/dialogs/resources/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from . import adaptive_card_example 5 | 6 | __all__ = ["adaptive_card_example"] 7 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .about import __title__, __version__ 5 | 6 | __all__ = ["__title__", "__version__"] 7 | -------------------------------------------------------------------------------- /samples/45.state-management/bots/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .state_management_bot import StateManagementBot 5 | 6 | __all__ = ["StateManagementBot"] 7 | -------------------------------------------------------------------------------- /samples/06.using-cards/helpers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from . import activity_helper, dialog_helper 5 | 6 | __all__ = ["activity_helper", "dialog_helper"] 7 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | default_stages: [push] 2 | repos: 3 | - repo: https://github.com/pre-commit/mirrors-pylint 4 | rev: v2.3.1 5 | hooks: 6 | - id: pylint 7 | files: libraries 8 | args: [--rcfile=.pylintrc] 9 | verbose: true -------------------------------------------------------------------------------- /samples/45.state-management/data_models/user_profile.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class UserProfile: 6 | def __init__(self, name: str = None): 7 | self.name = name 8 | -------------------------------------------------------------------------------- /Generator/generator-botbuilder-python/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/waterfall_step.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | # TODO: Remove this file once we get some tests to verify waterfall_step 5 | # unnecessary in Python. 6 | -------------------------------------------------------------------------------- /samples/13.core-bot/helpers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from . import activity_helper, luis_helper, dialog_helper 5 | 6 | __all__ = ["activity_helper", "dialog_helper", "luis_helper"] 7 | -------------------------------------------------------------------------------- /samples/13.core-bot/bots/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .dialog_bot import DialogBot 5 | from .dialog_and_welcome_bot import DialogAndWelcomeBot 6 | 7 | __all__ = ["DialogBot", "DialogAndWelcomeBot"] 8 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model/model_corebot101/bert/model_runtime/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .bert_model_runtime import BertModelRuntime 5 | 6 | __all__ = ["BertModelRuntime"] 7 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model/model_corebot101/bidaf/model_runtime/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .bidaf_model_runtime import BidafModelRuntime 5 | 6 | __all__ = ["BidafModelRuntime"] 7 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model_runtime_svc/model_runtime_svc_corebot101/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Model Runtime.""" 4 | from .model_cache import ModelCache 5 | 6 | __all__ = ["ModelCache"] 7 | -------------------------------------------------------------------------------- /samples/45.state-management/data_models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .conversation_data import ConversationData 5 | from .user_profile import UserProfile 6 | 7 | __all__ = ["ConversationData", "UserProfile"] 8 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/bot/helpers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Helpers module.""" 4 | 5 | from . import activity_helper, dialog_helper 6 | 7 | __all__ = ["activity_helper", "dialog_helper"] 8 | -------------------------------------------------------------------------------- /samples/python_django/13.core-bot/helpers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | """Helpers module.""" 5 | from . import activity_helper, luis_helper, dialog_helper 6 | 7 | __all__ = ["activity_helper", "dialog_helper", "luis_helper"] 8 | -------------------------------------------------------------------------------- /samples/21.corebot-app-insights/helpers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Helpers module.""" 4 | 5 | from . import activity_helper, luis_helper, dialog_helper 6 | 7 | __all__ = ["activity_helper", "dialog_helper", "luis_helper"] 8 | -------------------------------------------------------------------------------- /samples/python_django/13.core-bot/requirements.txt: -------------------------------------------------------------------------------- 1 | Django>=2.2.1 2 | requests>=2.18.1 3 | botframework-connector>=4.4.0.b1 4 | botbuilder-schema>=4.4.0.b1 5 | botbuilder-core>=4.4.0.b1 6 | botbuilder-dialogs>=4.4.0.b1 7 | botbuilder-ai>=4.4.0.b1 8 | datatypes-date-time>=1.0.0.a1 9 | azure-cognitiveservices-language-luis>=0.2.0 -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/state_property_info.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from abc import ABC 5 | 6 | 7 | class StatePropertyInfo(ABC): 8 | @property 9 | def name(self): 10 | raise NotImplementedError() 11 | -------------------------------------------------------------------------------- /libraries/botbuilder-testing/botbuilder/testing/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .dialog_test_client import DialogTestClient 5 | from .dialog_test_logger import DialogTestLogger 6 | 7 | 8 | __all__ = ["DialogTestClient", "DialogTestLogger"] 9 | -------------------------------------------------------------------------------- /samples/python_django/13.core-bot/bots/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """bots module.""" 4 | 5 | from .dialog_bot import DialogBot 6 | from .dialog_and_welcome_bot import DialogAndWelcomeBot 7 | 8 | __all__ = ["DialogBot", "DialogAndWelcomeBot"] 9 | -------------------------------------------------------------------------------- /samples/21.corebot-app-insights/bots/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """bots module.""" 4 | 5 | from .dialog_bot import DialogBot 6 | from .dialog_and_welcome_bot import DialogAndWelcomeBot 7 | 8 | __all__ = ["DialogBot", "DialogAndWelcomeBot"] 9 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/bot/bots/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """bots module.""" 4 | 5 | from .dialog_bot import DialogBot 6 | from .dialog_and_welcome_bot import DialogAndWelcomeBot 7 | 8 | __all__ = ["DialogBot", "DialogAndWelcomeBot"] 9 | -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/botbuilder/applicationinsights/flask/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Flask Application Insights package.""" 4 | 5 | from .flask_telemetry_middleware import BotTelemetryMiddleware 6 | 7 | __all__ = ["BotTelemetryMiddleware"] 8 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/auth/verify_options.py: -------------------------------------------------------------------------------- 1 | class VerifyOptions: 2 | def __init__(self, issuer, audience, clock_tolerance, ignore_expiration): 3 | self.issuer = issuer 4 | self.audience = audience 5 | self.clock_tolerance = clock_tolerance 6 | self.ignore_expiration = ignore_expiration 7 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/qna/test_data/NoAnswerFoundInKb.json: -------------------------------------------------------------------------------- 1 | { 2 | "answers": [ 3 | { 4 | "questions": [], 5 | "answer": "No good match found in KB.", 6 | "score": 0, 7 | "id": -1, 8 | "source": null, 9 | "metadata": [] 10 | } 11 | ], 12 | "debugInfo": null 13 | } -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/choices/list_style.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from enum import Enum 5 | 6 | 7 | class ListStyle(str, Enum): 8 | none = 0 9 | auto = 1 10 | in_line = 2 11 | list_style = 3 12 | suggested_action = 4 13 | hero_card = 5 14 | -------------------------------------------------------------------------------- /libraries/swagger/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generateclient", 3 | "version": "1.0.0", 4 | "description": "", 5 | "private": true, 6 | "author": "", 7 | "devDependencies": { 8 | "@microsoft.azure/autorest.python": "^4.0.67", 9 | "autorest": "^3.0.5165", 10 | "replace": "^1.0.0" 11 | }, 12 | "dependencies": {} 13 | } 14 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model/model_corebot101/bert/common/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .bert_util import BertUtil 5 | from .input_example import InputExample 6 | from .input_features import InputFeatures 7 | 8 | __all__ = ["BertUtil", "InputExample", "InputFeatures"] 9 | -------------------------------------------------------------------------------- /libraries/botbuilder-azure/.cache/v/cache/lastfailed: -------------------------------------------------------------------------------- 1 | { 2 | "tests/test_cosmos_storage.py": true, 3 | "tests/test_cosmos_storage.py::TestCosmosDbStorage::()::test_cosmos_storage_write_should_overwrite_cached_value_with_valid_newer_e_tag": true, 4 | "tests/test_cosmos_storage.py::TestCosmosDbStorage::()::test_cosmos_storage_write_should_raise_a_key_error_with_older_e_tag": true 5 | } -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/property_manager.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | from botbuilder.core.state_property_accessor import StatePropertyAccessor 4 | 5 | 6 | class PropertyManager: 7 | def create_property(self, name: str) -> StatePropertyAccessor: 8 | raise NotImplementedError() 9 | -------------------------------------------------------------------------------- /.cache/v/cache/lastfailed: -------------------------------------------------------------------------------- 1 | { 2 | "libraries/botbuilder-azure/tests/test_cosmos_storage.py": true, 3 | "libraries/botframework-connector/tests/test_attachments.py": true, 4 | "libraries/botframework-connector/tests/test_attachments_async.py": true, 5 | "libraries/botframework-connector/tests/test_conversations.py": true, 6 | "libraries/botframework-connector/tests/test_conversations_async.py": true 7 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/python-sdk-question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Python SDK Question 3 | about: The issue tracker is not for questions. Please ask questions on https://stackoverflow.com/questions/tagged/botframework 4 | 5 | --- 6 | 7 | 🚨 The issue tracker is not for questions 🚨 8 | 9 | If you have a question, please ask it on https://stackoverflow.com/questions/tagged/botframework 10 | 11 | [question] 12 | -------------------------------------------------------------------------------- /samples/21.corebot-app-insights/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask>=1.0.2 2 | asyncio>=3.4.3 3 | requests>=2.18.1 4 | botframework-connector>=4.4.0.b1 5 | botbuilder-schema>=4.4.0.b1 6 | botbuilder-core>=4.4.0.b1 7 | botbuilder-dialogs>=4.4.0.b1 8 | botbuilder-ai>=4.4.0.b1 9 | botbuilder-applicationinsights>=4.4.0.b1 10 | datatypes-date-time>=1.0.0.a1 11 | azure-cognitiveservices-language-luis>=0.2.0 12 | msrest>=0.6.6 13 | 14 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model/model_corebot101/bert/train/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Bert tuning training.""" 4 | 5 | from .args import Args 6 | from .bert_train_eval import BertTrainEval 7 | from .flight_booking_processor import FlightBookingProcessor 8 | 9 | __all__ = ["Args", "BertTrainEval", "FlightBookingProcessor"] 10 | -------------------------------------------------------------------------------- /samples/13.core-bot/dialogs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .booking_dialog import BookingDialog 5 | from .cancel_and_help_dialog import CancelAndHelpDialog 6 | from .date_resolver_dialog import DateResolverDialog 7 | from .main_dialog import MainDialog 8 | 9 | __all__ = ["BookingDialog", "CancelAndHelpDialog", "DateResolverDialog", "MainDialog"] 10 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/luis/test_data/V1DatetimeResolution.json: -------------------------------------------------------------------------------- 1 | { 2 | "query": "4", 3 | "topScoringIntent": { 4 | "intent": "None", 5 | "score": 0.8575135 6 | }, 7 | "entities": [ 8 | { 9 | "entity": "4", 10 | "type": "builtin.datetime.time", 11 | "startIndex": 0, 12 | "endIndex": 0, 13 | "resolution": { 14 | "comment": "ampm", 15 | "time": "T04" 16 | } 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/datetime_resolution.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class DateTimeResolution: 6 | def __init__( 7 | self, value: str = None, start: str = None, end: str = None, timex: str = None 8 | ): 9 | self.value = value 10 | self.start = start 11 | self.end = end 12 | self.timex = timex 13 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | services: 3 | bot: 4 | build: 5 | context: . 6 | dockerfile: Dockerfile_bot 7 | ports: 8 | - "3978:3978" 9 | links: 10 | - api 11 | environment: 12 | MODEL_RUNTIME_API_HOST : api 13 | 14 | api: 15 | build: 16 | context: . 17 | dockerfile: Dockerfile_model_runtime 18 | ports: 19 | - "8880:8880" 20 | 21 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/recognizer.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from abc import ABC, abstractmethod 5 | from .turn_context import TurnContext 6 | from .recognizer_result import RecognizerResult 7 | 8 | 9 | class Recognizer(ABC): 10 | @abstractmethod 11 | async def recognize(self, turn_context: TurnContext) -> RecognizerResult: 12 | raise NotImplementedError() 13 | -------------------------------------------------------------------------------- /samples/python_django/13.core-bot/dialogs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Dialogs module""" 4 | from .booking_dialog import BookingDialog 5 | from .cancel_and_help_dialog import CancelAndHelpDialog 6 | from .date_resolver_dialog import DateResolverDialog 7 | from .main_dialog import MainDialog 8 | 9 | __all__ = ["BookingDialog", "CancelAndHelpDialog", "DateResolverDialog", "MainDialog"] 10 | -------------------------------------------------------------------------------- /samples/21.corebot-app-insights/dialogs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Dialogs module""" 4 | from .booking_dialog import BookingDialog 5 | from .cancel_and_help_dialog import CancelAndHelpDialog 6 | from .date_resolver_dialog import DateResolverDialog 7 | from .main_dialog import MainDialog 8 | 9 | __all__ = ["BookingDialog", "CancelAndHelpDialog", "DateResolverDialog", "MainDialog"] 10 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/qna/test_data/ReturnsAnswer.json: -------------------------------------------------------------------------------- 1 | { 2 | "activeLearningEnabled": false, 3 | "answers": [ 4 | { 5 | "questions": [ 6 | "how do I clean the stove?" 7 | ], 8 | "answer": "BaseCamp: You can use a damp rag to clean around the Power Pack", 9 | "score": 100, 10 | "id": 5, 11 | "source": "Editorial", 12 | "metadata": [] 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/qna/test_data/AnswerWithHighScoreProvidedContext.json: -------------------------------------------------------------------------------- 1 | { 2 | "answers": [ 3 | { 4 | "questions": [ 5 | "Where can I buy cleaning products?" 6 | ], 7 | "answer": "Any DIY store", 8 | "score": 100, 9 | "id": 55, 10 | "source": "Editorial", 11 | "metadata": [], 12 | "context": { 13 | "isContextOnly": true, 14 | "prompts": [] 15 | } 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/bot/dialogs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Dialogs module""" 4 | from .booking_dialog import BookingDialog 5 | from .cancel_and_help_dialog import CancelAndHelpDialog 6 | from .date_resolver_dialog import DateResolverDialog 7 | from .main_dialog import MainDialog 8 | 9 | __all__ = ["BookingDialog", "CancelAndHelpDialog", "DateResolverDialog", "MainDialog"] 10 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/auth/claims_identity.py: -------------------------------------------------------------------------------- 1 | class Claim: 2 | def __init__(self, claim_type: str, value): 3 | self.type = claim_type 4 | self.value = value 5 | 6 | 7 | class ClaimsIdentity: 8 | def __init__(self, claims: dict, is_authenticated: bool): 9 | self.claims = claims 10 | self.is_authenticated = is_authenticated 11 | 12 | def get_claim_value(self, claim_type: str): 13 | return self.claims.get(claim_type) 14 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/adapters/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # -------------------------------------------------------------------------- 7 | 8 | from .test_adapter import TestAdapter, TestFlow 9 | 10 | __all__ = ["TestAdapter", "TestFlow"] 11 | -------------------------------------------------------------------------------- /samples/python_django/13.core-bot/booking_details.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | """Booking detail.""" 5 | 6 | 7 | class BookingDetails: 8 | """Booking detail implementation""" 9 | 10 | def __init__( 11 | self, destination: str = None, origin: str = None, travel_date: str = None 12 | ): 13 | self.destination = destination 14 | self.origin = origin 15 | self.travel_date = travel_date 16 | -------------------------------------------------------------------------------- /samples/21.corebot-app-insights/booking_details.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Booking detail.""" 4 | 5 | 6 | class BookingDetails: 7 | """Booking detail implementation""" 8 | 9 | def __init__( 10 | self, destination: str = None, origin: str = None, travel_date: str = None 11 | ): 12 | self.destination = destination 13 | self.origin = origin 14 | self.travel_date = travel_date 15 | -------------------------------------------------------------------------------- /samples/45.state-management/data_models/conversation_data.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class ConversationData: 6 | def __init__( 7 | self, 8 | timestamp: str = None, 9 | channel_id: str = None, 10 | prompted_for_user_name: bool = False, 11 | ): 12 | self.timestamp = timestamp 13 | self.channel_id = channel_id 14 | self.prompted_for_user_name = prompted_for_user_name 15 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model/model_corebot101/bert/common/input_features.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class InputFeatures(object): 6 | """A single set of features of data.""" 7 | 8 | def __init__(self, input_ids, input_mask, segment_ids, label_id): 9 | self.input_ids = input_ids 10 | self.input_mask = input_mask 11 | self.segment_ids = segment_ids 12 | self.label_id = label_id 13 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/choices/choice.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import List 5 | 6 | from botbuilder.schema import CardAction 7 | 8 | 9 | class Choice: 10 | def __init__( 11 | self, value: str = None, action: CardAction = None, synonyms: List[str] = None 12 | ): 13 | self.value: str = value 14 | self.action: CardAction = action 15 | self.synonyms: List[str] = synonyms 16 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/prompt_recognizer_result.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | """ Result returned by a prompts recognizer function. 5 | """ 6 | 7 | 8 | class PromptRecognizerResult: 9 | def __init__(self, succeeded: bool = False, value: object = None): 10 | """Creates result returned by a prompts recognizer function. 11 | """ 12 | self.succeeded = succeeded 13 | self.value = value 14 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/luis/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .luis_application import LuisApplication 5 | from .luis_prediction_options import LuisPredictionOptions 6 | from .luis_telemetry_constants import LuisTelemetryConstants 7 | from .luis_recognizer import LuisRecognizer 8 | 9 | __all__ = [ 10 | "LuisApplication", 11 | "LuisPredictionOptions", 12 | "LuisRecognizer", 13 | "LuisTelemetryConstants", 14 | ] 15 | -------------------------------------------------------------------------------- /samples/python_django/13.core-bot/bots/urls.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. 4 | 5 | """ URL configuration for bot message handler """ 6 | 7 | from django.urls import path 8 | from django.views.decorators.csrf import csrf_exempt 9 | from . import views 10 | 11 | # pylint:disable=invalid-name 12 | urlpatterns = [ 13 | path("", views.home, name="home"), 14 | path("api/messages", csrf_exempt(views.messages), name="messages"), 15 | ] 16 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/about.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | 6 | __title__ = "botbuilder-ai" 7 | __version__ = ( 8 | os.environ["packageVersion"] if "packageVersion" in os.environ else "4.4.0b1" 9 | ) 10 | __uri__ = "https://www.github.com/Microsoft/botbuilder-python" 11 | __author__ = "Microsoft" 12 | __description__ = "Microsoft Bot Framework Bot Builder" 13 | __summary__ = "Microsoft Bot Framework Bot Builder SDK for Python." 14 | __license__ = "MIT" 15 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/inspection/inspection_state.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from botbuilder.core import BotState, Storage, TurnContext 5 | 6 | 7 | class InspectionState(BotState): 8 | def __init__(self, storage: Storage): 9 | super().__init__(storage, self.__class__.__name__) 10 | 11 | def get_storage_key( # pylint: disable=unused-argument 12 | self, turn_context: TurnContext 13 | ) -> str: 14 | return self.__class__.__name__ 15 | -------------------------------------------------------------------------------- /libraries/botbuilder-azure/botbuilder/azure/about.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | 6 | __title__ = "botbuilder-azure" 7 | __version__ = ( 8 | os.environ["packageVersion"] if "packageVersion" in os.environ else "4.4.0b1" 9 | ) 10 | __uri__ = "https://www.github.com/Microsoft/botbuilder-python" 11 | __author__ = "Microsoft" 12 | __description__ = "Microsoft Bot Framework Bot Builder" 13 | __summary__ = "Microsoft Bot Framework Bot Builder SDK for Python." 14 | __license__ = "MIT" 15 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/about.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | 6 | __title__ = "botbuilder-core" 7 | __version__ = ( 8 | os.environ["packageVersion"] if "packageVersion" in os.environ else "4.4.0b1" 9 | ) 10 | __uri__ = "https://www.github.com/Microsoft/botbuilder-python" 11 | __author__ = "Microsoft" 12 | __description__ = "Microsoft Bot Framework Bot Builder" 13 | __summary__ = "Microsoft Bot Framework Bot Builder SDK for Python." 14 | __license__ = "MIT" 15 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_turn_result.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .dialog_turn_status import DialogTurnStatus 5 | 6 | 7 | class DialogTurnResult: 8 | def __init__(self, status: DialogTurnStatus, result: object = None): 9 | self._status = status 10 | self._result = result 11 | 12 | @property 13 | def status(self): 14 | return self._status 15 | 16 | @property 17 | def result(self): 18 | return self._result 19 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/about.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | 6 | __title__ = "botbuilder-dialogs" 7 | __version__ = ( 8 | os.environ["packageVersion"] if "packageVersion" in os.environ else "4.4.0b1" 9 | ) 10 | __uri__ = "https://www.github.com/Microsoft/botbuilder-python" 11 | __author__ = "Microsoft" 12 | __description__ = "Microsoft Bot Framework Bot Builder" 13 | __summary__ = "Microsoft Bot Framework Bot Builder SDK for Python." 14 | __license__ = "MIT" 15 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/luis/test_data/TraceActivity.json: -------------------------------------------------------------------------------- 1 | { 2 | "query": "My name is Emad", 3 | "topScoringIntent": { 4 | "intent": "SpecifyName", 5 | "score": 0.8785189 6 | }, 7 | "intents": [ 8 | { 9 | "intent": "SpecifyName", 10 | "score": 0.8785189 11 | } 12 | ], 13 | "entities": [ 14 | { 15 | "entity": "emad", 16 | "type": "Name", 17 | "startIndex": 11, 18 | "endIndex": 14, 19 | "score": 0.8446753 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /libraries/botbuilder-core/tests/call_counting_middleware.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import Awaitable, Callable 5 | from botbuilder.core import Middleware, TurnContext 6 | 7 | 8 | class CallCountingMiddleware(Middleware): 9 | def __init__(self): 10 | self.counter = 0 11 | 12 | def on_turn( # pylint: disable=unused-argument 13 | self, context: TurnContext, logic: Callable[[TurnContext], Awaitable] 14 | ): 15 | self.counter += 1 16 | logic() 17 | -------------------------------------------------------------------------------- /Generator/generator-botbuilder-python/__tests__/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const path = require('path'); 3 | const assert = require('yeoman-assert'); 4 | const helpers = require('yeoman-test'); 5 | 6 | describe('generator-botbuilder-python:app', () => { 7 | beforeAll(() => { 8 | return helpers 9 | .run(path.join(__dirname, '../generators/app')) 10 | .withPrompts({ someAnswer: true }); 11 | }); 12 | 13 | it('creates files', () => { 14 | assert.file(['main.py']); 15 | assert.file(['README.md']); 16 | assert.file(['requirements.txt']); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/inspection/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # -------------------------------------------------------------------------- 7 | 8 | from .inspection_middleware import InspectionMiddleware 9 | from .inspection_state import InspectionState 10 | 11 | __all__ = ["InspectionMiddleware", "InspectionState"] 12 | -------------------------------------------------------------------------------- /libraries/botbuilder-testing/botbuilder/testing/about.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | 6 | 7 | __title__ = "botbuilder-testing" 8 | __version__ = ( 9 | os.environ["packageVersion"] if "packageVersion" in os.environ else "4.4.0b1" 10 | ) 11 | __uri__ = "https://www.github.com/Microsoft/botbuilder-python" 12 | __author__ = "Microsoft" 13 | __description__ = "Microsoft Bot Framework Bot Builder" 14 | __summary__ = "Microsoft Bot Framework Bot Builder SDK for Python." 15 | __license__ = "MIT" 16 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/luis/test_data/SingleIntent_SimplyEntity.json: -------------------------------------------------------------------------------- 1 | { 2 | "query": "my name is Emad", 3 | "topScoringIntent": { 4 | "intent": "SpecifyName", 5 | "score": 0.8785189 6 | }, 7 | "intents": [ 8 | { 9 | "intent": "SpecifyName", 10 | "score": 0.8785189 11 | } 12 | ], 13 | "entities": [ 14 | { 15 | "entity": "emad", 16 | "type": "Name", 17 | "startIndex": 11, 18 | "endIndex": 14, 19 | "score": 0.8446753 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/version.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # 7 | # Code generated by Microsoft (R) AutoRest Code Generator. 8 | # Changes may cause incorrect behavior and will be lost if the code is 9 | # regenerated. 10 | # -------------------------------------------------------------------------- 11 | 12 | VERSION = "v3" 13 | -------------------------------------------------------------------------------- /samples/13.core-bot/booking_details.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import List 5 | 6 | 7 | class BookingDetails: 8 | def __init__( 9 | self, 10 | destination: str = None, 11 | origin: str = None, 12 | travel_date: str = None, 13 | unsupported_airports: List[str] = [], 14 | ): 15 | self.destination = destination 16 | self.origin = origin 17 | self.travel_date = travel_date 18 | self.unsupported_airports = unsupported_airports 19 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/token_api/version.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # 7 | # Code generated by Microsoft (R) AutoRest Code Generator. 8 | # Changes may cause incorrect behavior and will be lost if the code is 9 | # regenerated. 10 | # -------------------------------------------------------------------------- 11 | 12 | VERSION = "token" 13 | -------------------------------------------------------------------------------- /samples/python_django/13.core-bot/config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. 4 | 5 | """ Bot Configuration """ 6 | 7 | 8 | class DefaultConfig(object): 9 | """ Bot Configuration """ 10 | 11 | PORT = 3978 12 | APP_ID = "" 13 | APP_PASSWORD = "" 14 | 15 | LUIS_APP_ID = "" 16 | # LUIS authoring key from LUIS portal or LUIS Cognitive Service subscription key 17 | LUIS_API_KEY = "" 18 | # LUIS endpoint host name, ie "https://westus.api.cognitive.microsoft.com" 19 | LUIS_API_HOST_NAME = "" 20 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/models/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # 7 | # Code generated by Microsoft (R) AutoRest Code Generator. 8 | # Changes may cause incorrect behavior and will be lost if the code is 9 | # regenerated. 10 | # -------------------------------------------------------------------------- 11 | 12 | from botbuilder.schema import * 13 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model/model_corebot101/about.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Package information.""" 4 | import os 5 | 6 | __title__ = "model_corebot101" 7 | __version__ = ( 8 | os.environ["packageVersion"] if "packageVersion" in os.environ else "0.0.1" 9 | ) 10 | __uri__ = "https://www.github.com/Microsoft/botbuilder-python" 11 | __author__ = "Microsoft" 12 | __description__ = "Microsoft Bot Framework Bot Builder" 13 | __summary__ = "Microsoft Bot Framework Bot Builder SDK for Python." 14 | __license__ = "MIT" 15 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model/model_corebot101/booking_details.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Booking Details. 4 | The lu model will detect the properties of a flight booking. 5 | """ 6 | 7 | 8 | class BookingDetails: 9 | """Booking properties from lu model.""" 10 | 11 | def __init__( 12 | self, destination: str = None, origin: str = None, travel_date: str = None 13 | ): 14 | self.destination = destination 15 | self.origin = origin 16 | self.travel_date = travel_date 17 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model_runtime_svc/model_runtime_svc_corebot101/about.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | 6 | __title__ = "model_runtime_svc_corebot101" 7 | __version__ = ( 8 | os.environ["packageVersion"] if "packageVersion" in os.environ else "0.0.1" 9 | ) 10 | __uri__ = "https://www.github.com/Microsoft/botbuilder-python" 11 | __author__ = "Microsoft" 12 | __description__ = "Microsoft Bot Framework Bot Builder" 13 | __summary__ = "Microsoft Bot Framework Bot Builder SDK for Python." 14 | __license__ = "MIT" 15 | -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/authentication_stub.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from msrest.authentication import BasicTokenAuthentication, Authentication 5 | 6 | 7 | class MicrosoftTokenAuthenticationStub(Authentication): 8 | def __init__(self, access_token): 9 | self.access_token = access_token 10 | 11 | def signed_session(self, session=None): 12 | basic_authentication = BasicTokenAuthentication( 13 | {"access_token": self.access_token} 14 | ) 15 | return session or basic_authentication.signed_session() 16 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/choices/sorted_value.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class SortedValue: 6 | """ A value that can be sorted and still refer to its original position with a source array. """ 7 | 8 | def __init__(self, value: str, index: int): 9 | """ 10 | Parameters: 11 | ----------- 12 | 13 | value: The value that will be sorted. 14 | 15 | index: The values original position within its unsorted array. 16 | """ 17 | 18 | self.value = value 19 | self.index = index 20 | -------------------------------------------------------------------------------- /samples/python_django/13.core-bot/bots/wsgi.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. 4 | 5 | """ 6 | WSGI config for bots project. 7 | 8 | It exposes the WSGI callable as a module-level variable named ``application``. 9 | 10 | For more information on this file, see 11 | https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ 12 | """ 13 | 14 | import os 15 | from django.core.wsgi import get_wsgi_application 16 | 17 | # pylint:disable=invalid-name 18 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bots.settings") 19 | application = get_wsgi_application() 20 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/run_test.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | 4 | cd C:\Users\v-asho\Desktop\Python\botbuilder-python\libraries\botbuilder-ai 5 | 6 | python -m compileall . 7 | IF %ERRORLEVEL% NEQ 0 ( 8 | ECHO [Error] build failed! 9 | exit /b %errorlevel% 10 | ) 11 | 12 | python -O -m compileall . 13 | IF %ERRORLEVEL% NEQ 0 ( 14 | ECHO [Error] build failed! 15 | exit /b %errorlevel% 16 | ) 17 | 18 | pip install . 19 | IF %ERRORLEVEL% NEQ 0 ( 20 | ECHO [Error] DIALOGS Install failed! 21 | exit /b %errorlevel% 22 | ) 23 | 24 | python -m unittest discover ./tests 25 | IF %ERRORLEVEL% NEQ 0 ( 26 | ECHO [Error] Test failed! 27 | exit /b %errorlevel% 28 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_turn_status.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | from enum import Enum 4 | 5 | 6 | class DialogTurnStatus(Enum): 7 | # Indicates that there is currently nothing on the dialog stack. 8 | Empty = 1 9 | 10 | # Indicates that the dialog on top is waiting for a response from the user. 11 | Waiting = 2 12 | 13 | # Indicates that the dialog completed successfully, the result is available, and the stack is empty. 14 | Complete = 3 15 | 16 | # Indicates that the dialog was cancelled and the stack is empty. 17 | Cancelled = 4 18 | -------------------------------------------------------------------------------- /samples/13.core-bot/config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. 4 | 5 | import os 6 | 7 | """ Bot Configuration """ 8 | 9 | 10 | class DefaultConfig: 11 | """ Bot Configuration """ 12 | 13 | PORT = 3978 14 | APP_ID = os.environ.get("MicrosoftAppId", "") 15 | APP_PASSWORD = os.environ.get("MicrosoftAppPassword", "") 16 | LUIS_APP_ID = os.environ.get("LuisAppId", "") 17 | LUIS_API_KEY = os.environ.get("LuisAPIKey", "") 18 | # LUIS endpoint host name, ie "westus.api.cognitive.microsoft.com" 19 | LUIS_API_HOST_NAME = os.environ.get("LuisAPIHostName", "") 20 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/aio/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # 7 | # Code generated by Microsoft (R) AutoRest Code Generator. 8 | # Changes may cause incorrect behavior and will be lost if the code is 9 | # regenerated. 10 | # -------------------------------------------------------------------------- 11 | 12 | from ._connector_client_async import ConnectorClient 13 | 14 | __all__ = ["ConnectorClient"] 15 | -------------------------------------------------------------------------------- /samples/06.using-cards/config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. 4 | 5 | import os 6 | 7 | """ Bot Configuration """ 8 | 9 | 10 | class DefaultConfig: 11 | """ Bot Configuration """ 12 | 13 | PORT = 3978 14 | APP_ID = os.environ.get("MicrosoftAppId", "") 15 | APP_PASSWORD = os.environ.get("MicrosoftAppPassword", "") 16 | LUIS_APP_ID = os.environ.get("LuisAppId", "") 17 | LUIS_API_KEY = os.environ.get("LuisAPIKey", "") 18 | # LUIS endpoint host name, ie "westus.api.cognitive.microsoft.com" 19 | LUIS_API_HOST_NAME = os.environ.get("LuisAPIHostName", "") 20 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/token_api/aio/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # 7 | # Code generated by Microsoft (R) AutoRest Code Generator. 8 | # Changes may cause incorrect behavior and will be lost if the code is 9 | # regenerated. 10 | # -------------------------------------------------------------------------- 11 | 12 | from ._token_api_client_async import TokenApiClient 13 | 14 | __all__ = ["TokenApiClient"] 15 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/intent_score.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import Dict 5 | from msrest.serialization import Model 6 | 7 | 8 | class IntentScore(Model): 9 | _attribute_map = { 10 | "score": {"key": "score", "type": "float"}, 11 | "properties": {"key": "properties", "type": "{object}"}, 12 | } 13 | 14 | def __init__( 15 | self, score: float = None, properties: Dict[str, object] = None, **kwargs 16 | ): 17 | super(IntentScore, self).__init__(**kwargs) 18 | self.score = score 19 | self.properties = properties or {} 20 | -------------------------------------------------------------------------------- /samples/45.state-management/config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. 4 | 5 | import os 6 | 7 | """ Bot Configuration """ 8 | 9 | 10 | class DefaultConfig(object): 11 | """ Bot Configuration """ 12 | 13 | PORT = 3978 14 | APP_ID = os.environ.get("MicrosoftAppId", "") 15 | APP_PASSWORD = os.environ.get("MicrosoftAppPassword", "") 16 | LUIS_APP_ID = os.environ.get("LuisAppId", "") 17 | LUIS_API_KEY = os.environ.get("LuisAPIKey", "") 18 | # LUIS endpoint host name, ie "westus.api.cognitive.microsoft.com" 19 | LUIS_API_HOST_NAME = os.environ.get("LuisAPIHostName", "") 20 | -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/botbuilder/applicationinsights/about.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Bot Framework Application Insights integration package info.""" 4 | 5 | import os 6 | 7 | __title__ = "botbuilder-applicationinsights" 8 | __version__ = ( 9 | os.environ["packageVersion"] if "packageVersion" in os.environ else "4.4.0b1" 10 | ) 11 | __uri__ = "https://www.github.com/Microsoft/botbuilder-python" 12 | __author__ = "Microsoft" 13 | __description__ = "Microsoft Bot Framework Bot Builder" 14 | __summary__ = "Microsoft Bot Framework Bot Builder SDK for Python." 15 | __license__ = "MIT" 16 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/luis/test_data/MultipleIntents_ListEntityWithSingleValue.json: -------------------------------------------------------------------------------- 1 | { 2 | "query": "I want to travel on united", 3 | "topScoringIntent": { 4 | "intent": "Travel", 5 | "score": 0.8785189 6 | }, 7 | "intents": [ 8 | { 9 | "intent": "Travel", 10 | "score": 0.8785189 11 | } 12 | ], 13 | "entities": [ 14 | { 15 | "entity": "united", 16 | "type": "Airline", 17 | "startIndex": 20, 18 | "endIndex": 25, 19 | "resolution": { 20 | "values": [ 21 | "United" 22 | ] 23 | } 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/python-sdk-feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Python SDK Feature Request 3 | about: Suggest a feature for the Bot Builder Python SDK 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | 19 | [enhancement] 20 | -------------------------------------------------------------------------------- /samples/21.corebot-app-insights/NOTICE.md: -------------------------------------------------------------------------------- 1 | ## NOTICE 2 | 3 | Please note that while the 21.corebot-app-insights sample is licensed under the MIT license, the sample has dependencies that use other types of licenses. 4 | 5 | Since Microsoft does not modify nor distribute these dependencies, it is the sole responsibility of the user to determine the correct/compliant usage of these dependencies. Please refer to the 6 | [bot requirements](./bot/requirements.txt), [model requirements](./model/setup.py) and [model runtime requirements](./model_runtime_svc/setup.py) for a list of the **direct** dependencies. 7 | 8 | Please also note that the sample depends on the `requests` package, which has a dependency `chardet` that uses LGPL license. -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_instance.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import Dict 5 | 6 | 7 | class DialogInstance: 8 | """ 9 | Tracking information for a dialog on the stack. 10 | """ 11 | 12 | def __init__(self): 13 | self.id: str = None # pylint: disable=invalid-name 14 | self.state: Dict[str, object] = {} 15 | 16 | def __str__(self): 17 | result = "\ndialog_instance_id: %s\n" % self.id 18 | if self.state is not None: 19 | for key, value in self.state.items(): 20 | result += " {} ({})\n".format(key, str(value)) 21 | return result 22 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/NOTICE.md: -------------------------------------------------------------------------------- 1 | ## NOTICE 2 | 3 | Please note that while the 101.corebot-bert-bidaf sample is licensed under the MIT license, the sample has dependencies that use other types of licenses. 4 | 5 | Since Microsoft does not modify nor distribute these dependencies, it is the sole responsibility of the user to determine the correct/compliant usage of these dependencies. Please refer to the 6 | [bot requirements](./bot/requirements.txt), [model requirements](./model/setup.py) and [model runtime requirements](./model_runtime_svc/setup.py) for a list of the **direct** dependencies. 7 | 8 | Please also note that the sample depends on the `requests` package, which has a dependency `chardet` that uses LGPL license. -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/luis/test_data/MultipleIntents_ListEntityWithMultiValues.json: -------------------------------------------------------------------------------- 1 | { 2 | "query": "I want to travel on DL", 3 | "topScoringIntent": { 4 | "intent": "Travel", 5 | "score": 0.8785189 6 | }, 7 | "intents": [ 8 | { 9 | "intent": "Travel", 10 | "score": 0.8785189 11 | } 12 | ], 13 | "entities": [ 14 | { 15 | "entity": "dl", 16 | "type": "Airline", 17 | "startIndex": 20, 18 | "endIndex": 21, 19 | "resolution": { 20 | "values": [ 21 | "Virgin", 22 | "Delta" 23 | ] 24 | } 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_state.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import List 5 | from .dialog_instance import DialogInstance 6 | 7 | 8 | class DialogState: 9 | def __init__(self, stack: List[DialogInstance] = None): 10 | if stack is None: 11 | self._dialog_stack = [] 12 | else: 13 | self._dialog_stack = stack 14 | 15 | @property 16 | def dialog_stack(self): 17 | return self._dialog_stack 18 | 19 | def __str__(self): 20 | if not self._dialog_stack: 21 | return "dialog stack empty!" 22 | return " ".join(map(str, self._dialog_stack)) 23 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/qnamaker_endpoint.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class QnAMakerEndpoint: 6 | def __init__(self, knowledge_base_id: str, endpoint_key: str, host: str): 7 | if not knowledge_base_id: 8 | raise TypeError("QnAMakerEndpoint.knowledge_base_id cannot be empty.") 9 | 10 | if not endpoint_key: 11 | raise TypeError("QnAMakerEndpoint.endpoint_key cannot be empty.") 12 | 13 | if not host: 14 | raise TypeError("QnAMakerEndpoint.host cannot be empty.") 15 | 16 | self.knowledge_base_id = knowledge_base_id 17 | self.endpoint_key = endpoint_key 18 | self.host = host 19 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/qna/test_data/AnswerWithPrompts.json: -------------------------------------------------------------------------------- 1 | { 2 | "answers": [ 3 | { 4 | "questions": [ 5 | "how do I clean the stove?" 6 | ], 7 | "answer": "BaseCamp: You can use a damp rag to clean around the Power Pack", 8 | "score": 100, 9 | "id": 5, 10 | "source": "Editorial", 11 | "metadata": [], 12 | "context": { 13 | "isContextOnly": true, 14 | "prompts": [ 15 | { 16 | "displayOrder": 0, 17 | "qnaId": 55, 18 | "qna": null, 19 | "displayText": "Where can I buy?" 20 | } 21 | ] 22 | } 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/conversation_reference_extension.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | import uuid 4 | from botbuilder.schema import Activity, ActivityTypes, ConversationReference 5 | 6 | 7 | def get_continuation_activity(reference: ConversationReference) -> Activity: 8 | return Activity( 9 | type=ActivityTypes.event, 10 | name="ContinueConversation", 11 | id=str(uuid.uuid1()), 12 | channel_id=reference.channel_id, 13 | service_url=reference.service_url, 14 | conversation=reference.conversation, 15 | recipient=reference.bot, 16 | from_property=reference.user, 17 | relates_to=reference, 18 | ) 19 | -------------------------------------------------------------------------------- /samples/01.console-echo/bot.py: -------------------------------------------------------------------------------- 1 | from sys import exit 2 | 3 | 4 | class EchoBot: 5 | async def on_turn(self, context): 6 | # Check to see if this activity is an incoming message. 7 | # (It could theoretically be another type of activity.) 8 | if context.activity.type == "message" and context.activity.text: 9 | # Check to see if the user sent a simple "quit" message. 10 | if context.activity.text.lower() == "quit": 11 | # Send a reply. 12 | await context.send_activity("Bye!") 13 | exit(0) 14 | else: 15 | # Echo the message text back to the user. 16 | await context.send_activity(f"I heard you say {context.activity.text}") 17 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/tests/test_utilities.py: -------------------------------------------------------------------------------- 1 | from botbuilder.schema import ( 2 | Activity, 3 | ActivityTypes, 4 | ConversationAccount, 5 | ChannelAccount, 6 | ) 7 | from botbuilder.core import TurnContext 8 | from botbuilder.core.adapters import TestAdapter 9 | 10 | 11 | class TestUtilities: 12 | @staticmethod 13 | def create_empty_context(): 14 | adapter = TestAdapter() 15 | activity = Activity( 16 | type=ActivityTypes.message, 17 | channel_id="EmptyContext", 18 | conversation=ConversationAccount(id="test"), 19 | from_property=ChannelAccount(id="empty@empty.context.org"), 20 | ) 21 | context = TurnContext(adapter, activity) 22 | 23 | return context 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/python-sdk-bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Python SDK Bug 3 | about: Create a bug report for a bug you found in the Bot Builder Python SDK 4 | 5 | --- 6 | 7 | ## Version 8 | What package version of the SDK are you using. 9 | 10 | ## Describe the bug 11 | Give a clear and concise description of what the bug is. 12 | 13 | ## To Reproduce 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | ## Expected behavior 21 | Give a clear and concise description of what you expected to happen. 22 | 23 | ## Screenshots 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | ## Additional context 27 | Add any other context about the problem here. 28 | 29 | [bug] 30 | -------------------------------------------------------------------------------- /libraries/botbuilder-azure/botbuilder/azure/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # -------------------------------------------------------------------------- 7 | 8 | from .about import __version__ 9 | from .cosmosdb_storage import CosmosDbStorage, CosmosDbConfig, CosmosDbKeyEscape 10 | from .blob_storage import BlobStorage, BlobStorageSettings 11 | 12 | __all__ = [ 13 | "BlobStorage", 14 | "BlobStorageSettings", 15 | "CosmosDbStorage", 16 | "CosmosDbConfig", 17 | "CosmosDbKeyEscape", 18 | "__version__", 19 | ] 20 | -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/botbuilder/applicationinsights/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # -------------------------------------------------------------------------- 7 | 8 | from .application_insights_telemetry_client import ( 9 | ApplicationInsightsTelemetryClient, 10 | bot_telemetry_processor, 11 | ) 12 | from .bot_telemetry_processor import BotTelemetryProcessor 13 | 14 | 15 | __all__ = [ 16 | "ApplicationInsightsTelemetryClient", 17 | "BotTelemetryProcessor", 18 | "bot_telemetry_processor", 19 | ] 20 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/models/feedback_records.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import List 5 | 6 | from msrest.serialization import Model 7 | 8 | from .feedback_record import FeedbackRecord 9 | 10 | 11 | class FeedbackRecords(Model): 12 | """ Active learning feedback records. """ 13 | 14 | _attribute_map = {"records": {"key": "records", "type": "[FeedbackRecord]"}} 15 | 16 | def __init__(self, records: List[FeedbackRecord], **kwargs): 17 | """ 18 | Parameter(s): 19 | ------------- 20 | 21 | records: List of feedback records. 22 | """ 23 | 24 | super().__init__(**kwargs) 25 | 26 | self.records = records 27 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/token_api/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # 7 | # Code generated by Microsoft (R) AutoRest Code Generator. 8 | # Changes may cause incorrect behavior and will be lost if the code is 9 | # regenerated. 10 | # -------------------------------------------------------------------------- 11 | 12 | from ._bot_sign_in_operations import BotSignInOperations 13 | from ._user_token_operations import UserTokenOperations 14 | 15 | __all__ = ["BotSignInOperations", "UserTokenOperations"] 16 | -------------------------------------------------------------------------------- /samples/21.corebot-app-insights/config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. 4 | """Configuration for the bot.""" 5 | 6 | import os 7 | 8 | 9 | class DefaultConfig: 10 | """Configuration for the bot.""" 11 | 12 | PORT = 3978 13 | APP_ID = os.environ.get("MicrosoftAppId", "") 14 | APP_PASSWORD = os.environ.get("MicrosoftAppPassword", "") 15 | LUIS_APP_ID = os.environ.get("LuisAppId", "") 16 | LUIS_API_KEY = os.environ.get("LuisAPIKey", "") 17 | # LUIS endpoint host name, ie "westus.api.cognitive.microsoft.com" 18 | LUIS_API_HOST_NAME = os.environ.get("LuisAPIHostName", "") 19 | APPINSIGHTS_INSTRUMENTATION_KEY = os.environ.get("AppInsightsInstrumentationKey", "") 20 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # 7 | # Code generated by Microsoft (R) AutoRest Code Generator. 8 | # Changes may cause incorrect behavior and will be lost if the code is 9 | # regenerated. 10 | # -------------------------------------------------------------------------- 11 | 12 | from ._attachments_operations import AttachmentsOperations 13 | from ._conversations_operations import ConversationsOperations 14 | 15 | __all__ = ["AttachmentsOperations", "ConversationsOperations"] 16 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/token_api/aio/operations_async/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # 7 | # Code generated by Microsoft (R) AutoRest Code Generator. 8 | # Changes may cause incorrect behavior and will be lost if the code is 9 | # regenerated. 10 | # -------------------------------------------------------------------------- 11 | 12 | from ._bot_sign_in_operations_async import BotSignInOperations 13 | from ._user_token_operations_async import UserTokenOperations 14 | 15 | __all__ = ["BotSignInOperations", "UserTokenOperations"] 16 | -------------------------------------------------------------------------------- /samples/13.core-bot/helpers/dialog_helper.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from botbuilder.core import StatePropertyAccessor, TurnContext 5 | from botbuilder.dialogs import Dialog, DialogSet, DialogTurnStatus 6 | 7 | 8 | class DialogHelper: 9 | @staticmethod 10 | async def run_dialog( 11 | dialog: Dialog, turn_context: TurnContext, accessor: StatePropertyAccessor 12 | ): 13 | dialog_set = DialogSet(accessor) 14 | dialog_set.add(dialog) 15 | 16 | dialog_context = await dialog_set.create_context(turn_context) 17 | results = await dialog_context.continue_dialog() 18 | if results.status == DialogTurnStatus.Empty: 19 | await dialog_context.begin_dialog(dialog.id) 20 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/telemetry_logger_constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License 3 | 4 | 5 | class TelemetryLoggerConstants: 6 | """The Telemetry Logger Event names.""" 7 | 8 | # The name of the event when a new message is received from the user. 9 | BOT_MSG_RECEIVE_EVENT: str = "BotMessageReceived" 10 | 11 | # The name of the event when logged when a message is sent from the bot to the user. 12 | BOT_MSG_SEND_EVENT: str = "BotMessageSend" 13 | 14 | # The name of the event when a message is updated by the bot. 15 | BOT_MSG_UPDATE_EVENT: str = "BotMessageUpdate" 16 | 17 | # The name of the event when a message is deleted by the bot. 18 | BOT_MSG_DELETE_EVENT: str = "BotMessageDelete" 19 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/choices/found_value.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class FoundValue: 6 | """ Represents a result from matching user input against a list of choices """ 7 | 8 | def __init__(self, value: str, index: int, score: float): 9 | """ 10 | Parameters: 11 | ---------- 12 | 13 | value: The value that was matched. 14 | index: The index of the value that was matched. 15 | score: The accuracy with which the synonym matched the specified portion of the utterance. 16 | A value of 1.0 would indicate a perfect match. 17 | 18 | """ 19 | self.value = value 20 | self.index = index 21 | self.score = score 22 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/aio/operations_async/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # 7 | # Code generated by Microsoft (R) AutoRest Code Generator. 8 | # Changes may cause incorrect behavior and will be lost if the code is 9 | # regenerated. 10 | # -------------------------------------------------------------------------- 11 | 12 | from ._attachments_operations_async import AttachmentsOperations 13 | from ._conversations_operations_async import ConversationsOperations 14 | 15 | __all__ = ["AttachmentsOperations", "ConversationsOperations"] 16 | -------------------------------------------------------------------------------- /samples/06.using-cards/helpers/dialog_helper.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from botbuilder.core import StatePropertyAccessor, TurnContext 5 | from botbuilder.dialogs import Dialog, DialogSet, DialogTurnStatus 6 | 7 | 8 | class DialogHelper: 9 | @staticmethod 10 | async def run_dialog( 11 | dialog: Dialog, turn_context: TurnContext, accessor: StatePropertyAccessor 12 | ): 13 | dialog_set = DialogSet(accessor) 14 | dialog_set.add(dialog) 15 | 16 | dialog_context = await dialog_set.create_context(turn_context) 17 | results = await dialog_context.continue_dialog() 18 | if results.status == DialogTurnStatus.Empty: 19 | await dialog_context.begin_dialog(dialog.id) 20 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/inspection/inspection_sessions_by_status.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import Dict 5 | 6 | from botbuilder.schema import ConversationReference 7 | 8 | 9 | class InspectionSessionsByStatus: 10 | def __init__( 11 | self, 12 | opened_sessions: Dict[str, ConversationReference] = None, 13 | attached_sessions: Dict[str, ConversationReference] = None, 14 | ): 15 | self.opened_sessions: Dict[str, ConversationReference] = opened_sessions or {} 16 | self.attached_sessions: Dict[ 17 | str, ConversationReference 18 | ] = attached_sessions or {} 19 | 20 | 21 | DEFAULT_INSPECTION_SESSIONS_BY_STATUS = InspectionSessionsByStatus() 22 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/models/metadata.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from msrest.serialization import Model 5 | 6 | 7 | class Metadata(Model): 8 | """ Metadata associated with the answer. """ 9 | 10 | _attribute_map = { 11 | "name": {"key": "name", "type": "str"}, 12 | "value": {"key": "value", "type": "str"}, 13 | } 14 | 15 | def __init__(self, name: str, value: str, **kwargs): 16 | """ 17 | Parameters: 18 | ----------- 19 | 20 | name: Metadata name. Max length: 100. 21 | 22 | value: Metadata value. Max length: 100. 23 | """ 24 | 25 | super().__init__(**kwargs) 26 | 27 | self.name = name 28 | self.value = value 29 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model_runtime_svc/model_runtime_svc_corebot101/docker_init.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Docker initialization. 4 | This is called from the Dockerfile when creating the model runtime service API 5 | container. 6 | """ 7 | import os 8 | from pathlib import Path 9 | from model_corebot101.language_helper import LanguageHelper 10 | 11 | # Initialize the models 12 | LH = LanguageHelper() 13 | HOME_DIR = str(Path.home()) 14 | BERT_MODEL_DIR_DEFAULT = os.path.abspath(os.path.join(HOME_DIR, "models/bert")) 15 | BIDAF_MODEL_DIR_DEFAULT = os.path.abspath(os.path.join(HOME_DIR, "models/bidaf")) 16 | 17 | LH.initialize_models( 18 | bert_model_dir=BERT_MODEL_DIR_DEFAULT, bidaf_model_dir=BIDAF_MODEL_DIR_DEFAULT 19 | ) 20 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/token_api/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # 7 | # Code generated by Microsoft (R) AutoRest Code Generator. 8 | # Changes may cause incorrect behavior and will be lost if the code is 9 | # regenerated. 10 | # -------------------------------------------------------------------------- 11 | 12 | from ._configuration import TokenApiClientConfiguration 13 | from ._token_api_client import TokenApiClient 14 | 15 | __all__ = ["TokenApiClient", "TokenApiClientConfiguration"] 16 | 17 | from .version import VERSION 18 | 19 | __version__ = VERSION 20 | -------------------------------------------------------------------------------- /samples/01.console-echo/main.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import asyncio 5 | from botbuilder.core import TurnContext, ConversationState, UserState, MemoryStorage 6 | from botbuilder.schema import ActivityTypes 7 | 8 | from adapter import ConsoleAdapter 9 | from bot import EchoBot 10 | 11 | # Create adapter 12 | adapter = ConsoleAdapter() 13 | bot = EchoBot() 14 | 15 | loop = asyncio.get_event_loop() 16 | 17 | if __name__ == "__main__": 18 | try: 19 | # Greet user 20 | print("Hi... I'm an echobot. Whatever you say I'll echo back.") 21 | 22 | loop.run_until_complete(adapter.process_activity(bot.on_turn)) 23 | except KeyboardInterrupt: 24 | pass 25 | finally: 26 | loop.stop() 27 | loop.close() 28 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/qnamaker_options.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .models import Metadata, QnARequestContext 5 | 6 | # figure out if 300 milliseconds is ok for python requests library...or 100000 7 | class QnAMakerOptions: 8 | def __init__( 9 | self, 10 | score_threshold: float = 0.0, 11 | timeout: int = 0, 12 | top: int = 0, 13 | strict_filters: [Metadata] = None, 14 | context: [QnARequestContext] = None, 15 | qna_id: int = None, 16 | ): 17 | self.score_threshold = score_threshold 18 | self.timeout = timeout 19 | self.top = top 20 | self.strict_filters = strict_filters or [] 21 | self.context = context 22 | self.qna_id = qna_id 23 | -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/botbuilder/applicationinsights/flask/flask_telemetry_processor.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Telemetry processor for Flask.""" 4 | import sys 5 | 6 | from ..processor.telemetry_processor import TelemetryProcessor 7 | from .flask_telemetry_middleware import retrieve_flask_body 8 | 9 | 10 | class FlaskTelemetryProcessor(TelemetryProcessor): 11 | def can_process(self) -> bool: 12 | return self.detect_flask() 13 | 14 | def get_request_body(self) -> str: 15 | if self.detect_flask(): 16 | return retrieve_flask_body() 17 | return None 18 | 19 | @staticmethod 20 | def detect_flask() -> bool: 21 | """Detects if running in flask.""" 22 | return "flask" in sys.modules 23 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # -------------------------------------------------------------------------- 7 | 8 | from .active_learning_utils import ActiveLearningUtils 9 | from .generate_answer_utils import GenerateAnswerUtils 10 | from .http_request_utils import HttpRequestUtils 11 | from .qna_telemetry_constants import QnATelemetryConstants 12 | from .train_utils import TrainUtils 13 | 14 | __all__ = [ 15 | "ActiveLearningUtils", 16 | "GenerateAnswerUtils", 17 | "HttpRequestUtils", 18 | "QnATelemetryConstants", 19 | "TrainUtils", 20 | ] 21 | -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/botbuilder/applicationinsights/django/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Django Application Insights package.""" 4 | 5 | from . import common 6 | from .bot_telemetry_middleware import BotTelemetryMiddleware 7 | from .logging import LoggingHandler 8 | from .middleware import ApplicationInsightsMiddleware 9 | 10 | 11 | __all__ = [ 12 | "BotTelemetryMiddleware", 13 | "ApplicationInsightsMiddleware", 14 | "LoggingHandler", 15 | "create_client", 16 | ] 17 | 18 | 19 | def create_client(): 20 | """Returns an :class:`applicationinsights.TelemetryClient` instance using the instrumentation key 21 | and other settings found in the current Django project's `settings.py` file.""" 22 | return common.create_client() 23 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # 7 | # Code generated by Microsoft (R) AutoRest Code Generator. 8 | # Changes may cause incorrect behavior and will be lost if the code is 9 | # regenerated. 10 | # -------------------------------------------------------------------------- 11 | 12 | from .channels import Channels 13 | from .connector_client import ConnectorClient 14 | from .emulator_api_client import EmulatorApiClient 15 | from .version import VERSION 16 | 17 | __all__ = ["Channels", "ConnectorClient", "EmulatorApiClient"] 18 | 19 | __version__ = VERSION 20 | -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/django_tests/urls.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from django.conf.urls import include, url 5 | from django.contrib import admin 6 | 7 | from . import views 8 | 9 | urlpatterns = [ 10 | url(r"^$", views.home, name="home"), 11 | url(r"^logger$", views.logger, name="logger"), 12 | url(r"^botlog_event$", views.botlog_event, name="botlog_event"), 13 | url(r"^thrower$", views.thrower, name="thrower"), 14 | url(r"^errorer$", views.errorer, name="errorer"), 15 | url(r"^getid/([0-9]+)$", views.getid, name="getid"), 16 | url(r"^returncode/([0-9]+)$", views.returncode, name="returncode"), 17 | url(r"^templater/([^/]*)$", views.templater, name="templater"), 18 | url(r"^class$", views.classview(), name="class"), 19 | ] 20 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/invoke_response.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class InvokeResponse: 6 | """ 7 | Tuple class containing an HTTP Status Code and a JSON Serializable 8 | object. The HTTP Status code is, in the invoke activity scenario, what will 9 | be set in the resulting POST. The Body of the resulting POST will be 10 | the JSON Serialized content from the Body property. 11 | """ 12 | 13 | def __init__(self, status: int = None, body: object = None): 14 | """ 15 | Gets or sets the HTTP status and/or body code for the response 16 | :param status: The HTTP status code. 17 | :param body: The body content for the response. 18 | """ 19 | self.status = status 20 | self.body = body 21 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/utils/qna_telemetry_constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from enum import Enum 5 | 6 | 7 | class QnATelemetryConstants(str, Enum): 8 | """ 9 | Default QnA event and property names logged using IBotTelemetryClient. 10 | """ 11 | 12 | qna_message_event = "QnaMessage" 13 | """Event name""" 14 | knowledge_base_id_property = "knowledgeBaseId" 15 | answer_property = "answer" 16 | article_found_property = "articleFound" 17 | channel_id_property = "channelId" 18 | conversation_id_property = "conversationId" 19 | question_property = "question" 20 | matched_question_property = "matchedQuestion" 21 | question_id_property = "questionId" 22 | score_metric = "score" 23 | username_property = "username" 24 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/telemetry_constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License 3 | 4 | 5 | class TelemetryConstants: 6 | """Telemetry logger property names.""" 7 | 8 | CHANNEL_ID_PROPERTY: str = "channelId" 9 | CONVERSATION_ID_PROPERTY: str = "conversationId" 10 | CONVERSATION_NAME_PROPERTY: str = "conversationName" 11 | DIALOG_ID_PROPERTY: str = "dialogId" 12 | FROM_ID_PROPERTY: str = "fromId" 13 | FROM_NAME_PROPERTY: str = "fromName" 14 | LOCALE_PROPERTY: str = "locale" 15 | RECIPIENT_ID_PROPERTY: str = "recipientId" 16 | RECIPIENT_NAME_PROPERTY: str = "recipientName" 17 | REPLY_ACTIVITY_ID_PROPERTY: str = "replyActivityId" 18 | TEXT_PROPERTY: str = "text" 19 | SPEAK_PROPERTY: str = "speak" 20 | USER_ID_PROPERTY: str = "userId" 21 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/qna/test_data/AnswerWithLowScoreProvidedWithoutContext.json: -------------------------------------------------------------------------------- 1 | { 2 | "answers": [ 3 | { 4 | "questions": [ 5 | "Where can I buy home appliances?" 6 | ], 7 | "answer": "Any Walmart store", 8 | "score": 68, 9 | "id": 56, 10 | "source": "Editorial", 11 | "metadata": [], 12 | "context": { 13 | "isContextOnly": false, 14 | "prompts": [] 15 | } 16 | }, 17 | { 18 | "questions": [ 19 | "Where can I buy cleaning products?" 20 | ], 21 | "answer": "Any DIY store", 22 | "score": 56, 23 | "id": 55, 24 | "source": "Editorial", 25 | "metadata": [], 26 | "context": { 27 | "isContextOnly": false, 28 | "prompts": [] 29 | } 30 | } 31 | ] 32 | } -------------------------------------------------------------------------------- /libraries/botbuilder-core/tests/test_message.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from botbuilder.schema import ( 5 | Activity, 6 | ActivityTypes, 7 | ChannelAccount, 8 | ConversationAccount, 9 | ) 10 | 11 | 12 | class TestMessage: 13 | @staticmethod 14 | def message(id: str = "1234") -> Activity: # pylint: disable=invalid-name 15 | return Activity( 16 | type=ActivityTypes.message, 17 | id=id, 18 | text="test", 19 | from_property=ChannelAccount(id="user", name="User Name"), 20 | recipient=ChannelAccount(id="bot", name="Bot Name"), 21 | conversation=ConversationAccount(id="convo", name="Convo Name"), 22 | channel_id="UnitTest", 23 | service_url="https://example.org", 24 | ) 25 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/prompt_options.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import List 5 | 6 | from botbuilder.schema import Activity 7 | from botbuilder.dialogs.choices import Choice, ListStyle 8 | 9 | 10 | class PromptOptions: 11 | def __init__( 12 | self, 13 | prompt: Activity = None, 14 | retry_prompt: Activity = None, 15 | choices: List[Choice] = None, 16 | style: ListStyle = None, 17 | validations: object = None, 18 | number_of_attempts: int = 0, 19 | ): 20 | self.prompt = prompt 21 | self.retry_prompt = retry_prompt 22 | self.choices = choices 23 | self.style = style 24 | self.validations = validations 25 | self.number_of_attempts = number_of_attempts 26 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/models/train_request_body.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import List 5 | from msrest.serialization import Model 6 | 7 | from .feedback_record import FeedbackRecord 8 | 9 | 10 | class TrainRequestBody(Model): 11 | """ Class the models the request body that is sent as feedback to the Train API. """ 12 | 13 | _attribute_map = { 14 | "feedback_records": {"key": "feedbackRecords", "type": "[FeedbackRecord]"} 15 | } 16 | 17 | def __init__(self, feedback_records: List[FeedbackRecord], **kwargs): 18 | """ 19 | Parameters: 20 | ----------- 21 | 22 | feedback_records: List of feedback records. 23 | """ 24 | 25 | super().__init__(**kwargs) 26 | 27 | self.feedback_records = feedback_records 28 | -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/botbuilder/applicationinsights/django/django_telemetry_processor.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Telemetry processor for Django.""" 4 | import sys 5 | 6 | from ..processor.telemetry_processor import TelemetryProcessor 7 | from .bot_telemetry_middleware import retrieve_bot_body 8 | 9 | 10 | class DjangoTelemetryProcessor(TelemetryProcessor): 11 | def can_process(self) -> bool: 12 | return self.detect_django() 13 | 14 | def get_request_body(self) -> str: 15 | if self.detect_django(): 16 | # Retrieve from Middleware cache 17 | return retrieve_bot_body() 18 | return None 19 | 20 | @staticmethod 21 | def detect_django() -> bool: 22 | """Detects if running in django.""" 23 | return "django" in sys.modules 24 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/luis/luis_telemetry_constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from enum import Enum 5 | 6 | 7 | class LuisTelemetryConstants(str, Enum): 8 | """ 9 | The IBotTelemetryClient event and property names that logged by default. 10 | """ 11 | 12 | luis_result = "LuisResult" 13 | """Event name""" 14 | application_id_property = "applicationId" 15 | intent_property = "intent" 16 | intent_score_property = "intentScore" 17 | intent2_property = "intent2" 18 | intent_score2_property = "intentScore2" 19 | entities_property = "entities" 20 | question_property = "question" 21 | activity_id_property = "activityId" 22 | sentiment_label_property = "sentimentLabel" 23 | sentiment_score_property = "sentimentScore" 24 | from_id_property = "fromId" 25 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/dialog_reason.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | from enum import Enum 4 | 5 | 6 | class DialogReason(Enum): 7 | # A dialog is being started through a call to `DialogContext.begin()`. 8 | BeginCalled = 1 9 | # A dialog is being continued through a call to `DialogContext.continue_dialog()`. 10 | ContinueCalled = 2 11 | # A dialog ended normally through a call to `DialogContext.end_dialog()`. 12 | EndCalled = 3 13 | # A dialog is ending because it's being replaced through a call to `DialogContext.replace_dialog()`. 14 | ReplaceCalled = 4 15 | # A dialog was cancelled as part of a call to `DialogContext.cancel_all_dialogs()`. 16 | CancelCalled = 5 17 | # A step was advanced through a call to `WaterfallStepContext.next()`. 18 | NextCalled = 6 19 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/tests/test_dialog_set.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import aiounittest 5 | from botbuilder.dialogs import DialogSet, ComponentDialog 6 | from botbuilder.core import ConversationState, MemoryStorage 7 | 8 | 9 | class DialogSetTests(aiounittest.AsyncTestCase): 10 | def test_dialogset_constructor_valid(self): 11 | convo_state = ConversationState(MemoryStorage()) 12 | dialog_state_property = convo_state.create_property("dialogstate") 13 | dialog_set = DialogSet(dialog_state_property) 14 | assert dialog_set is not None 15 | 16 | def test_dialogset_constructor_null_property(self): 17 | self.assertRaises(TypeError, lambda: DialogSet(None)) 18 | 19 | def test_dialogset_constructor_null_from_componentdialog(self): 20 | ComponentDialog("MyId") 21 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/luis/null_adapter.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import List 5 | 6 | from botbuilder.core import BotAdapter, TurnContext 7 | from botbuilder.schema import Activity, ConversationReference, ResourceResponse 8 | 9 | 10 | class NullAdapter(BotAdapter): 11 | """ 12 | This is a BotAdapter that does nothing on the Send operation, equivalent to piping to /dev/null. 13 | """ 14 | 15 | async def send_activities(self, context: TurnContext, activities: List[Activity]): 16 | return [ResourceResponse()] 17 | 18 | async def update_activity(self, context: TurnContext, activity: Activity): 19 | raise NotImplementedError() 20 | 21 | async def delete_activity( 22 | self, context: TurnContext, reference: ConversationReference 23 | ): 24 | raise NotImplementedError() 25 | -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/django_tests/run_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. 5 | 6 | # It is expected at this point that django and applicationinsights are both installed into a 7 | # virtualenv. 8 | django_version=$(python -c "import django ; print('.'.join(map(str, django.VERSION[0:2])))") 9 | test $? -eq 0 || exit 1 10 | 11 | # Create a new temporary work directory 12 | TMPDIR=$(mktemp -d) 13 | SRCDIR=$(pwd) 14 | function cleanup 15 | { 16 | cd $SRCDIR 17 | rm -rf $TMPDIR 18 | exit $1 19 | } 20 | trap cleanup EXIT SIGINT 21 | cd $TMPDIR 22 | 23 | # Set up Django project 24 | django-admin startproject aitest 25 | cd aitest 26 | cp $SRCDIR/views.py aitest/views.py 27 | cp $SRCDIR/tests.py aitest/tests.py 28 | cp $SRCDIR/urls.py aitest/urls.py 29 | cp $SRCDIR/template.html aitest/template.html 30 | 31 | ./manage.py test 32 | exit $? -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/choices/token.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class Token: 6 | """ Represents an individual token, such as a word in an input string. """ 7 | 8 | def __init__(self, start: int, end: int, text: str, normalized: str): 9 | """ 10 | Parameters: 11 | ---------- 12 | 13 | start: The index of the first character of the token within the outer input string. 14 | 15 | end: The index of the last character of the token within the outer input string. 16 | 17 | text: The original text of the token. 18 | 19 | normalized: A normalized version of the token. This can include things like lower casing or stemming. 20 | """ 21 | self.start = start 22 | self.end = end 23 | self.text = text 24 | self.normalized = normalized 25 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/choices/find_choices_options.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .find_values_options import FindValuesOptions 5 | 6 | 7 | class FindChoicesOptions(FindValuesOptions): 8 | """ Contains options to control how input is matched against a list of choices """ 9 | 10 | def __init__(self, no_value: bool = None, no_action: bool = None, **kwargs): 11 | """ 12 | Parameters: 13 | ----------- 14 | 15 | no_value: (Optional) If `True`, the choices `value` field will NOT be search over. Defaults to `False`. 16 | 17 | no_action: (Optional) If `True`, the choices `action.title` field will NOT be searched over. 18 | Defaults to `False`. 19 | """ 20 | 21 | super().__init__(**kwargs) 22 | self.no_value = no_value 23 | self.no_action = no_action 24 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/auth/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # 7 | # Code generated by Microsoft (R) AutoRest Code Generator. 8 | # Changes may cause incorrect behavior and will be lost if the code is 9 | # regenerated. 10 | # -------------------------------------------------------------------------- 11 | # pylint: disable=missing-docstring 12 | 13 | from .microsoft_app_credentials import * 14 | from .jwt_token_validation import * 15 | from .credential_provider import * 16 | from .channel_validation import * 17 | from .emulator_validation import * 18 | from .jwt_token_extractor import * 19 | from .government_constants import * 20 | from .authentication_constants import * 21 | -------------------------------------------------------------------------------- /samples/python_django/13.core-bot/helpers/dialog_helper.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Utility to run dialogs.""" 4 | from botbuilder.core import StatePropertyAccessor, TurnContext 5 | from botbuilder.dialogs import Dialog, DialogSet, DialogTurnStatus 6 | 7 | 8 | class DialogHelper: 9 | """Dialog Helper implementation.""" 10 | 11 | @staticmethod 12 | async def run_dialog( 13 | dialog: Dialog, turn_context: TurnContext, accessor: StatePropertyAccessor 14 | ): # pylint: disable=line-too-long 15 | """Run dialog.""" 16 | dialog_set = DialogSet(accessor) 17 | dialog_set.add(dialog) 18 | 19 | dialog_context = await dialog_set.create_context(turn_context) 20 | results = await dialog_context.continue_dialog() 21 | if results.status == DialogTurnStatus.Empty: 22 | await dialog_context.begin_dialog(dialog.id) 23 | -------------------------------------------------------------------------------- /doc/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributing 3 | 4 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 5 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 6 | the rights to use your contribution. For details, visit https://cla.microsoft.com. 7 | 8 | When you submit a pull request, a CLA-bot will automatically determine whether you need to provide 9 | a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions 10 | provided by the bot. You will only need to do this once across all repos using our CLA. 11 | 12 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 13 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 14 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 15 | -------------------------------------------------------------------------------- /samples/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Contributing 3 | 4 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 5 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 6 | the rights to use your contribution. For details, visit https://cla.microsoft.com. 7 | 8 | When you submit a pull request, a CLA-bot will automatically determine whether you need to provide 9 | a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions 10 | provided by the bot. You will only need to do this once across all repos using our CLA. 11 | 12 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 13 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 14 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 15 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/choices/found_choice.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class FoundChoice: 6 | """ Represents a result from matching user input against a list of choices """ 7 | 8 | def __init__(self, value: str, index: int, score: float, synonym: str = None): 9 | """ 10 | Parameters: 11 | ---------- 12 | 13 | value: The value of the choice that was matched. 14 | index: The index of the choice within the list of choices that was searched over. 15 | 16 | score: The accuracy with which the synonym matched the specified portion of the utterance. 17 | A value of 1.0 would indicate a perfect match. 18 | 19 | synonym: (Optional) The synonym that was matched. 20 | """ 21 | self.value = value 22 | self.index = index 23 | self.score = score 24 | self.synonym = synonym 25 | -------------------------------------------------------------------------------- /samples/21.corebot-app-insights/helpers/dialog_helper.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Utility to run dialogs.""" 4 | from botbuilder.core import StatePropertyAccessor, TurnContext 5 | from botbuilder.dialogs import Dialog, DialogSet, DialogTurnStatus 6 | 7 | 8 | class DialogHelper: 9 | """Dialog Helper implementation.""" 10 | 11 | @staticmethod 12 | async def run_dialog( 13 | dialog: Dialog, turn_context: TurnContext, accessor: StatePropertyAccessor 14 | ): # pylint: disable=line-too-long 15 | """Run dialog.""" 16 | dialog_set = DialogSet(accessor) 17 | dialog_set.add(dialog) 18 | 19 | dialog_context = await dialog_set.create_context(turn_context) 20 | results = await dialog_context.continue_dialog() 21 | if results.status == DialogTurnStatus.Empty: 22 | await dialog_context.begin_dialog(dialog.id) 23 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/tests/choices/test_choice.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | from typing import List 6 | 7 | from botbuilder.dialogs.choices import Choice 8 | from botbuilder.schema import CardAction 9 | 10 | 11 | class ChoiceTest(unittest.TestCase): 12 | def test_value_round_trips(self) -> None: 13 | choice = Choice() 14 | expected = "any" 15 | choice.value = expected 16 | self.assertIs(expected, choice.value) 17 | 18 | def test_action_round_trips(self) -> None: 19 | choice = Choice() 20 | expected = CardAction() 21 | choice.action = expected 22 | self.assertIs(expected, choice.action) 23 | 24 | def test_synonyms_round_trips(self) -> None: 25 | choice = Choice() 26 | expected: List[str] = [] 27 | choice.synonyms = expected 28 | self.assertIs(expected, choice.synonyms) 29 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/models/feedback_record.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from msrest.serialization import Model 5 | 6 | 7 | class FeedbackRecord(Model): 8 | """ Active learning feedback record. """ 9 | 10 | _attribute_map = { 11 | "user_id": {"key": "userId", "type": "str"}, 12 | "user_question": {"key": "userQuestion", "type": "str"}, 13 | "qna_id": {"key": "qnaId", "type": "int"}, 14 | } 15 | 16 | def __init__(self, user_id: str, user_question: str, qna_id: int, **kwargs): 17 | """ 18 | Parameters: 19 | ----------- 20 | 21 | user_id: ID of the user. 22 | 23 | user_question: User question. 24 | 25 | qna_id: QnA ID. 26 | """ 27 | 28 | super().__init__(**kwargs) 29 | 30 | self.user_id = user_id 31 | self.user_question = user_question 32 | self.qna_id = qna_id 33 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/choices/model_result.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class ModelResult: 6 | """Contains recognition result information.""" 7 | 8 | def __init__( 9 | self, text: str, start: int, end: int, type_name: str, resolution: object 10 | ): 11 | """ 12 | Parameters: 13 | ---------- 14 | 15 | text: Substring of the utterance that was recognized. 16 | 17 | start: Start character position of the recognized substring. 18 | 19 | end: The end character position of the recognized substring. 20 | 21 | type_name: The type of the entity that was recognized. 22 | 23 | resolution: The recognized entity object. 24 | """ 25 | self.text = text 26 | self.start = start 27 | self.end = end 28 | self.type_name = type_name 29 | self.resolution = resolution 30 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/bot/helpers/dialog_helper.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Utility to run dialogs.""" 4 | from botbuilder.core import StatePropertyAccessor, TurnContext 5 | from botbuilder.dialogs import Dialog, DialogSet, DialogTurnStatus 6 | 7 | 8 | class DialogHelper: 9 | """Dialog Helper implementation.""" 10 | 11 | @staticmethod 12 | async def run_dialog( 13 | dialog: Dialog, turn_context: TurnContext, accessor: StatePropertyAccessor 14 | ): # pylint: disable=line-too-long 15 | """Run dialog.""" 16 | dialog_set = DialogSet(accessor) 17 | dialog_set.add(dialog) 18 | 19 | dialog_context = await dialog_set.create_context(turn_context) 20 | results = await dialog_context.continue_dialog() 21 | if results.status == DialogTurnStatus.Empty: 22 | await dialog_context.begin_dialog(dialog.id) 23 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/emulator_api_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import requests 5 | from .auth import MicrosoftAppCredentials 6 | 7 | 8 | class EmulatorApiClient: 9 | @staticmethod 10 | async def emulate_oauth_cards( 11 | credentials: MicrosoftAppCredentials, emulator_url: str, emulate: bool 12 | ) -> bool: 13 | token = await credentials.get_token() 14 | request_url = ( 15 | emulator_url 16 | + ("" if emulator_url[-1] == "/" else "/") 17 | + f"api/usertoken/emulateOAuthCards?emulate={ str(emulate).lower() }" 18 | ) 19 | 20 | res = requests.post(request_url, headers={"Authorization": f"Bearer { token }"}) 21 | 22 | if res.status_code == 200: 23 | return True 24 | 25 | raise Exception( 26 | f"EmulateOAuthCards failed with status code: { res.status_code }" 27 | ) 28 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/oauth_prompt_settings.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class OAuthPromptSettings: 6 | def __init__( 7 | self, connection_name: str, title: str, text: str = None, timeout: int = None 8 | ): 9 | """ 10 | Settings used to configure an `OAuthPrompt` instance. 11 | Parameters: 12 | connection_name (str): Name of the OAuth connection being used. 13 | title (str): The title of the cards signin button. 14 | text (str): (Optional) additional text included on the signin card. 15 | timeout (int): (Optional) number of milliseconds the prompt will wait for the user to authenticate. 16 | `OAuthPrompt` defaults value to `900,000` ms (15 minutes). 17 | """ 18 | self.connection_name = connection_name 19 | self.title = title 20 | self.text = text 21 | self.timeout = timeout 22 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/bot/config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. 4 | """Bot/Flask Configuration parameters. 5 | Configuration parameters for the bot. 6 | """ 7 | 8 | 9 | class DefaultConfig(object): 10 | """Bot configuration parameters.""" 11 | 12 | # TCP port that the bot listens on (default:3978) 13 | PORT = 3978 14 | 15 | # Azure Application ID (not required if running locally) 16 | APP_ID = "" 17 | # Azure Application Password (not required if running locally) 18 | APP_PASSWORD = "" 19 | 20 | # Determines if the bot calls the models in-proc to the bot or call out of process 21 | # to the service api. 22 | USE_MODEL_RUNTIME_SERVICE = False 23 | # Host serving the out-of-process model runtime service api. 24 | MODEL_RUNTIME_SERVICE_HOST = "localhost" 25 | # TCP serving the out-of-process model runtime service api. 26 | MODEL_RUNTIME_SERVICE_PORT = 8880 27 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/qnamaker_telemetry_client.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from abc import ABC, abstractmethod 5 | from typing import Dict 6 | from botbuilder.core import BotTelemetryClient, TurnContext 7 | from .qnamaker_options import QnAMakerOptions 8 | 9 | 10 | class QnAMakerTelemetryClient(ABC): 11 | def __init__( 12 | self, log_personal_information: bool, telemetry_client: BotTelemetryClient 13 | ): 14 | self.log_personal_information = (log_personal_information,) 15 | self.telemetry_client = telemetry_client 16 | 17 | @abstractmethod 18 | def get_answers( 19 | self, 20 | context: TurnContext, 21 | options: QnAMakerOptions = None, 22 | telemetry_properties: Dict[str, str] = None, 23 | telemetry_metrics: Dict[str, float] = None, 24 | ): 25 | raise NotImplementedError( 26 | "QnAMakerTelemetryClient.get_answers(): is not implemented." 27 | ) 28 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/bot_state_set.py: -------------------------------------------------------------------------------- 1 | from asyncio import wait 2 | from typing import List 3 | from .bot_state import BotState 4 | from .turn_context import TurnContext 5 | 6 | 7 | class BotStateSet: 8 | def __init__(self, bot_states: List[BotState]): 9 | self.bot_states = list(bot_states) 10 | 11 | def add(self, bot_state: BotState) -> "BotStateSet": 12 | if bot_state is None: 13 | raise TypeError("Expected BotState") 14 | 15 | self.bot_states.append(bot_state) 16 | return self 17 | 18 | async def load_all(self, turn_context: TurnContext, force: bool = False): 19 | await wait( 20 | [bot_state.load(turn_context, force) for bot_state in self.bot_states] 21 | ) 22 | 23 | async def save_all_changes(self, turn_context: TurnContext, force: bool = False): 24 | await wait( 25 | [ 26 | bot_state.save_changes(turn_context, force) 27 | for bot_state in self.bot_states 28 | ] 29 | ) 30 | -------------------------------------------------------------------------------- /libraries/swagger/tokenAPI.md: -------------------------------------------------------------------------------- 1 | # BotFramework Token 2 | 3 | > see https://aka.ms/autorest 4 | 5 | Configuration for generating BotFramework Token SDK. 6 | 7 | ``` yaml 8 | add-credentials: true 9 | openapi-type: data-plane 10 | ``` 11 | The current release for the BotFramework Token is v3.0. 12 | 13 | # Releases 14 | 15 | ## Token API 3.0 16 | 17 | ``` yaml 18 | input-file: TokenAPI.json 19 | ``` 20 | 21 | ### Token API 3.0 - Python Settings 22 | 23 | These settings apply only when `--python` is specified on the command line. 24 | DO NOT use `--basic-setup-py` as this will overwrite the existing setup.py files. 25 | If you upgrade autorest from npm you may need to run `autorest ---reset` before continuing. 26 | 27 | ``` yaml $(python) 28 | python: 29 | license-header: MICROSOFT_MIT_NO_VERSION 30 | add-credentials: true 31 | payload-flattening-threshold: 2 32 | namespace: botframework.tokenApi 33 | package-name: botframework-Token 34 | override-client-name: TokenApiClient 35 | clear-output-folder: true 36 | output-folder: ./tokenApi 37 | ``` -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/models/query_results.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import List 5 | from msrest.serialization import Model 6 | from .query_result import QueryResult 7 | 8 | 9 | class QueryResults(Model): 10 | """ Contains answers for a user query. """ 11 | 12 | _attribute_map = { 13 | "answers": {"key": "answers", "type": "[QueryResult]"}, 14 | "active_learning_enabled": {"key": "activeLearningEnabled", "type": "bool"}, 15 | } 16 | 17 | def __init__( 18 | self, answers: List[QueryResult], active_learning_enabled: bool = None, **kwargs 19 | ): 20 | """ 21 | Parameters: 22 | ----------- 23 | 24 | answers: The answers for a user query. 25 | 26 | active_learning_enabled: The active learning enable flag. 27 | """ 28 | super(QueryResults, self).__init__(**kwargs) 29 | self.answers = answers 30 | self.active_learning_enabled = active_learning_enabled 31 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/tests/test_prompt_validator_context.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import aiounittest 5 | from botbuilder.dialogs import DialogSet 6 | from botbuilder.core import MemoryStorage, ConversationState 7 | 8 | 9 | class PromptValidatorContextTests(aiounittest.AsyncTestCase): 10 | async def test_prompt_validator_context_end(self): 11 | storage = MemoryStorage() 12 | conv = ConversationState(storage) 13 | accessor = conv.create_property("dialogstate") 14 | dialog_set = DialogSet(accessor) 15 | self.assertNotEqual(dialog_set, None) 16 | # TODO: Add TestFlow 17 | 18 | def test_prompt_validator_context_retry_end(self): 19 | storage = MemoryStorage() 20 | conv = ConversationState(storage) 21 | accessor = conv.create_property("dialogstate") 22 | dialog_set = DialogSet(accessor) 23 | self.assertNotEqual(dialog_set, None) 24 | # TODO: Add TestFlow 25 | 26 | # All require Testflow! 27 | -------------------------------------------------------------------------------- /samples/python_django/13.core-bot/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. 4 | 5 | """Django's command-line utility for administrative tasks.""" 6 | import os 7 | import sys 8 | from django.core.management.commands.runserver import Command as runserver 9 | import config 10 | 11 | 12 | def main(): 13 | """Django's command-line utility for administrative tasks.""" 14 | runserver.default_port = config.DefaultConfig.PORT 15 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bots.settings") 16 | try: 17 | from django.core.management import execute_from_command_line 18 | except ImportError as exc: 19 | raise ImportError( 20 | "Couldn't import Django. Are you sure it's installed and " 21 | "available on your PYTHONPATH environment variable? Did you " 22 | "forget to activate a virtual environment?" 23 | ) from exc 24 | execute_from_command_line(sys.argv) 25 | 26 | 27 | if __name__ == "__main__": 28 | main() 29 | -------------------------------------------------------------------------------- /libraries/swagger/README.md: -------------------------------------------------------------------------------- 1 | # BotFramework Connector 2 | 3 | > see https://aka.ms/autorest 4 | 5 | Configuration for generating BotFramework Connector SDK. 6 | 7 | ``` yaml 8 | add-credentials: true 9 | openapi-type: data-plane 10 | ``` 11 | The current release for the BotFramework Connector is v3.0. 12 | 13 | # Releases 14 | 15 | ## Connector API 3.0 16 | 17 | ``` yaml 18 | input-file: ConnectorAPI.json 19 | ``` 20 | 21 | ### Connector API 3.0 - Python Settings 22 | 23 | These settings apply only when `--python` is specified on the command line. 24 | DO NOT use `--basic-setup-py` as this will overwrite the existing setup.py files. 25 | If you upgrade autorest from npm you may need to run `autorest ---reset` before continuing. 26 | 27 | ``` yaml $(python) 28 | python: 29 | license-header: MICROSOFT_MIT_NO_VERSION 30 | add-credentials: true 31 | payload-flattening-threshold: 2 32 | namespace: botframework.connector 33 | package-name: botframework-connector 34 | override-client-name: ConnectorClient 35 | clear-output-folder: true 36 | output-folder: ./generated 37 | ``` -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/Dockerfile_bot: -------------------------------------------------------------------------------- 1 | FROM tiangolo/uwsgi-nginx-flask:python3.6 2 | 3 | # Setup for nginx 4 | RUN mkdir -p /home/LogFiles \ 5 | && apt update \ 6 | && apt install -y --no-install-recommends vim 7 | 8 | EXPOSE 3978 9 | 10 | COPY /model /model 11 | 12 | # Pytorch very large. Install from wheel. 13 | RUN wget https://files.pythonhosted.org/packages/69/60/f685fb2cfb3088736bafbc9bdbb455327bdc8906b606da9c9a81bae1c81e/torch-1.1.0-cp36-cp36m-manylinux1_x86_64.whl 14 | RUN pip3 install torch-1.1.0-cp36-cp36m-manylinux1_x86_64.whl 15 | 16 | RUN pip3 install -e /model/ 17 | 18 | 19 | COPY ./bot /bot 20 | 21 | RUN pip3 install -r /bot/requirements.txt 22 | 23 | ENV FLASK_APP=/bot/main.py 24 | ENV LANG=C.UTF-8 25 | ENV LC_ALL=C.UTF-8 26 | ENV PATH ${PATH}:/home/site/wwwroot 27 | 28 | WORKDIR bot 29 | # Initialize models 30 | 31 | 32 | # For Debugging, uncomment the following: 33 | #ENTRYPOINT ["python3.6", "-c", "import time ; time.sleep(500000)"] 34 | ENTRYPOINT [ "flask" ] 35 | CMD [ "run", "--port", "3978", "--host", "0.0.0.0" ] 36 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/models/qna_request_context.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from msrest.serialization import Model 5 | 6 | 7 | class QnARequestContext(Model): 8 | """ 9 | The context associated with QnA. 10 | Used to mark if the current prompt is relevant with a previous question or not. 11 | """ 12 | 13 | _attribute_map = { 14 | "previous_qna_id": {"key": "previousQnAId", "type": "int"}, 15 | "prvious_user_query": {"key": "previousUserQuery", "type": "string"}, 16 | } 17 | 18 | def __init__(self, previous_qna_id: int, prvious_user_query: str, **kwargs): 19 | """ 20 | Parameters: 21 | ----------- 22 | 23 | previous_qna_id: The previous QnA Id that was returned. 24 | 25 | prvious_user_query: The previous user query/question. 26 | """ 27 | 28 | super().__init__(**kwargs) 29 | 30 | self.previous_qna_id = previous_qna_id 31 | self.prvious_user_query = prvious_user_query 32 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .qnamaker import QnAMaker 5 | from .qnamaker_endpoint import QnAMakerEndpoint 6 | from .qnamaker_options import QnAMakerOptions 7 | from .qnamaker_telemetry_client import QnAMakerTelemetryClient 8 | from .utils import ( 9 | ActiveLearningUtils, 10 | GenerateAnswerUtils, 11 | HttpRequestUtils, 12 | QnATelemetryConstants, 13 | ) 14 | 15 | from .models import ( 16 | FeedbackRecord, 17 | FeedbackRecords, 18 | Metadata, 19 | QnAMakerTraceInfo, 20 | QueryResult, 21 | QueryResults, 22 | ) 23 | 24 | __all__ = [ 25 | "ActiveLearningUtils", 26 | "FeedbackRecord", 27 | "FeedbackRecords", 28 | "GenerateAnswerUtils", 29 | "HttpRequestUtils", 30 | "Metadata", 31 | "QueryResult", 32 | "QueryResults", 33 | "QnAMaker", 34 | "QnAMakerEndpoint", 35 | "QnAMakerOptions", 36 | "QnAMakerTelemetryClient", 37 | "QnAMakerTraceInfo", 38 | "QnATelemetryConstants", 39 | ] 40 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model/model_corebot101/bert/common/input_example.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class InputExample(object): 6 | """A single training/test example for sequence classification.""" 7 | 8 | def __init__(self, guid, text_a, text_b=None, label=None): 9 | """Constructs a InputExample. 10 | 11 | Args: 12 | guid: Unique id for the example. 13 | text_a: string. The untokenized text of the first sequence. For single 14 | sequence tasks, only this sequence must be specified. 15 | text_b: (Optional) string. The untokenized text of the second sequence. 16 | Only must be specified for sequence pair tasks. 17 | label: (Optional) string. The label of the example. This should be 18 | specified for train and dev examples, but not for test examples. 19 | """ 20 | self.guid = guid 21 | self.text_a = text_a 22 | self.text_b = text_b 23 | self.label = label 24 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/bot/requirements.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | # Note: The model must be built first! 5 | # cd model 6 | # 7 | 8 | # The following are installed outside of requirements.txt 9 | # conda install -c pytorch pytorch -y 10 | # pip install onnxruntime 11 | # Install python package dependencies with the following: 12 | # `pip install -r requirements.txt` 13 | 14 | # Bot 15 | Flask>=1.0.2 16 | asyncio>=3.4.3 17 | requests>=2.18.1 18 | 19 | # Bot Framework 20 | botframework-connector>=4.4.0.b1 21 | botbuilder-schema>=4.4.0.b1 22 | botbuilder-core>=4.4.0.b1 23 | botbuilder-dialogs>=4.4.0.b1 24 | botbuilder-ai>=4.4.0.b1 25 | datatypes-date-time>=1.0.0.a1 26 | azure-cognitiveservices-language-luis>=0.2.0 27 | msrest>=0.6.6 28 | 29 | # Internal library - must be built first! 30 | model_corebot101>=0.0.1 31 | 32 | torch 33 | onnx 34 | onnxruntime 35 | tqdm>=4.32.1 36 | pytorch-pretrained-bert>=0.6.2 37 | nltk>=3.4.1 38 | numpy>=1.16.3 39 | scipy>=1.3.0 40 | scikit-learn>=0.21.2 41 | 42 | -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/recordings/test_attachments_get_attachment_view_with_invalid_attachment_id_fails.yaml: -------------------------------------------------------------------------------- 1 | interactions: 2 | - request: 3 | body: null 4 | headers: 5 | Accept: [application/json] 6 | Accept-Encoding: ['gzip, deflate'] 7 | Connection: [keep-alive] 8 | Content-Type: [application/json; charset=utf-8] 9 | User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.1 msrest/0.4.23 10 | azure-botframework-connector/3.0] 11 | method: GET 12 | uri: https://slack.botframework.com/v3/attachments/bt13796-GJS4yaxDLI/views/original 13 | response: 14 | body: {string: ''} 15 | headers: 16 | cache-control: [no-cache] 17 | content-length: ['0'] 18 | date: ['Fri, 29 Dec 2017 18:29:54 GMT'] 19 | expires: ['-1'] 20 | pragma: [no-cache] 21 | request-context: ['appId=cid-v1:6814484e-c0d5-40ea-9dba-74ff29ca4f62'] 22 | server: [Microsoft-IIS/10.0] 23 | strict-transport-security: [max-age=31536000] 24 | x-powered-by: [ASP.NET] 25 | status: {code: 404, message: Not Found} 26 | version: 1 27 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/models/qna_response_context.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import List 5 | from msrest.serialization import Model 6 | from .prompt import Prompt 7 | 8 | 9 | class QnAResponseContext(Model): 10 | """ 11 | The context associated with QnA. 12 | Used to mark if the qna response has related prompts. 13 | """ 14 | 15 | _attribute_map = { 16 | "is_context_only": {"key": "isContextOnly", "type": "bool"}, 17 | "prompts": {"key": "prompts", "type": "[Prompt]"}, 18 | } 19 | 20 | def __init__( 21 | self, *, is_context_only: bool = False, prompts: List[Prompt] = None, **kwargs 22 | ): 23 | """ 24 | Parameters: 25 | ----------- 26 | 27 | is_context_only: Whether this prompt is context only. 28 | 29 | prompts: The prompts collection of related prompts. 30 | 31 | """ 32 | 33 | super(QnAResponseContext, self).__init__(**kwargs) 34 | self.is_context_only = is_context_only 35 | self.prompts = prompts 36 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/requirements.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | # Note: The model must be built first! 5 | # cd model 6 | # 7 | 8 | # The following are installed outside of requirements.txt 9 | # conda install -c pytorch pytorch -y 10 | # pip install onnxruntime 11 | # Install python package dependencies with the following: 12 | # `pip install -r requirements.txt` 13 | 14 | # Bot 15 | Flask>=1.0.2 16 | asyncio>=3.4.3 17 | requests>=2.18.1 18 | 19 | # Bot Framework 20 | botframework-connector>=4.4.0.b1 21 | botbuilder-schema>=4.4.0.b1 22 | botbuilder-core>=4.4.0.b1 23 | botbuilder-dialogs>=4.4.0.b1 24 | botbuilder-ai>=4.4.0.b1 25 | datatypes-date-time>=1.0.0.a1 26 | azure-cognitiveservices-language-luis>=0.2.0 27 | msrest>=0.6.6 28 | 29 | # Internal library - must be built first! 30 | model_corebot101>=0.0.1 31 | 32 | torch 33 | onnx 34 | onnxruntime 35 | tqdm>=4.32.1 36 | pytorch-pretrained-bert>=0.6.2 37 | nltk>=3.4.1 38 | numpy>=1.16.3 39 | scipy>=1.3.0 40 | scikit-learn>=0.21.2 41 | 42 | -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/recordings/test_attachments_get_info_invalid_attachment_id_fails.yaml: -------------------------------------------------------------------------------- 1 | interactions: 2 | - request: 3 | body: null 4 | headers: 5 | Accept: [application/json] 6 | Accept-Encoding: ['gzip, deflate'] 7 | Connection: [keep-alive] 8 | Content-Type: [application/json; charset=utf-8] 9 | User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.1 msrest/0.4.23 10 | azure-botframework-connector/3.0] 11 | method: GET 12 | uri: https://slack.botframework.com/v3/attachments/bt13796-GJS4yaxDLI 13 | response: 14 | body: {string: '"NotFound"'} 15 | headers: 16 | cache-control: [no-cache] 17 | content-length: ['10'] 18 | content-type: [application/json; charset=utf-8] 19 | date: ['Fri, 29 Dec 2017 18:24:36 GMT'] 20 | expires: ['-1'] 21 | pragma: [no-cache] 22 | request-context: ['appId=cid-v1:6814484e-c0d5-40ea-9dba-74ff29ca4f62'] 23 | server: [Microsoft-IIS/10.0] 24 | strict-transport-security: [max-age=31536000] 25 | x-powered-by: [ASP.NET] 26 | status: {code: 404, message: Not Found} 27 | version: 1 28 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/auto_save_state_middleware.py: -------------------------------------------------------------------------------- 1 | from typing import Awaitable, Callable, List, Union 2 | 3 | from .bot_state import BotState 4 | from .bot_state_set import BotStateSet 5 | from .middleware_set import Middleware 6 | from .turn_context import TurnContext 7 | 8 | 9 | class AutoSaveStateMiddleware(Middleware): 10 | def __init__(self, bot_states: Union[List[BotState], BotStateSet] = None): 11 | if bot_states is None: 12 | bot_states = [] 13 | if isinstance(bot_states, BotStateSet): 14 | self.bot_state_set: BotStateSet = bot_states 15 | else: 16 | self.bot_state_set: BotStateSet = BotStateSet(bot_states) 17 | 18 | def add(self, bot_state: BotState) -> "AutoSaveStateMiddleware": 19 | if bot_state is None: 20 | raise TypeError("Expected BotState") 21 | 22 | self.bot_state_set.add(bot_state) 23 | return self 24 | 25 | async def on_turn( 26 | self, context: TurnContext, logic: Callable[[TurnContext], Awaitable] 27 | ): 28 | await logic() 29 | await self.bot_state_set.save_all_changes(context, False) 30 | -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/django_tests/README.md: -------------------------------------------------------------------------------- 1 | # DJANGO-specific tests 2 | Django generates *code* to create projects (`django-admin startproject`) and apps. For testing, we test the generated code. The tests are bare-bones to be compatible across different versions of django. 3 | 4 | - This project contains a script to execute tests against currently supported version(s) of python and django. 5 | - Assume latest version of Application Insights. 6 | - Relies on virtualenv to run all tests. 7 | - Uses django commands to generate new project and execute django tests. 8 | - To run, first `cd django_tests` and then `bash .\all_tests.sh` (ie, in Powershell) to run all permutations. 9 | 10 | File | | Description 11 | --- | --- 12 | all_tests.sh | Runs our current test matrix of python/django versions. Current matrix is python (3.7) and django (2.2). 13 | README.md | This file. 14 | run_test.sh | Runs specific python/django version to create project, copy replacement files and runs tests. 15 | template.html | Template file 16 | tests.py | Django tests. 17 | urls.py | url paths called by tests 18 | views.py | paths that are called 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /samples/06.using-cards/bots/rich_cards_bot.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from botbuilder.core import MessageFactory, TurnContext 5 | from botbuilder.schema import ChannelAccount 6 | from .dialog_bot import DialogBot 7 | 8 | """ 9 | RichCardsBot prompts a user to select a Rich Card and then returns the card 10 | that matches the user's selection. 11 | """ 12 | 13 | 14 | class RichCardsBot(DialogBot): 15 | def __init__(self, conversation_state, user_state, dialog): 16 | super().__init__(conversation_state, user_state, dialog) 17 | 18 | async def on_members_added_activity( 19 | self, members_added: ChannelAccount, turn_context: TurnContext 20 | ): 21 | for member in members_added: 22 | if member.id != turn_context.activity.recipient.id: 23 | reply = MessageFactory.text( 24 | "Welcome to CardBot. " 25 | + "This bot will show you different types of Rich Cards. " 26 | + "Please type anything to get started." 27 | ) 28 | await turn_context.send_activity(reply) 29 | -------------------------------------------------------------------------------- /Generator/generator-botbuilder-python/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Microsoft 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/auth/constants.py: -------------------------------------------------------------------------------- 1 | class Constants: # pylint: disable=too-few-public-methods 2 | """ 3 | TO CHANNEL FROM BOT: Login URL prefix 4 | """ 5 | 6 | TO_CHANNEL_FROM_BOT_LOGIN_URL_PREFIX = "https://login.microsoftonline.com/" 7 | 8 | """ 9 | TO CHANNEL FROM BOT: Login URL token endpoint path 10 | """ 11 | TO_CHANNEL_FROM_BOT_TOKEN_ENDPOINT_PATH = "/oauth2/v2.0/token" 12 | 13 | """ 14 | TO CHANNEL FROM BOT: Default tenant from which to obtain a token for bot to channel communication 15 | """ 16 | DEFAULT_CHANNEL_AUTH_TENANT = "botframework.com" 17 | 18 | TO_BOT_FROM_CHANNEL_TOKEN_ISSUER = "https://api.botframework.com" 19 | 20 | TO_BOT_FROM_EMULATOR_OPEN_ID_METADATA_URL = ( 21 | "https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration" 22 | ) 23 | TO_BOT_FROM_CHANNEL_OPEN_ID_METADATA_URL = ( 24 | "https://login.botframework.com/v1/.well-known/openidconfiguration" 25 | ) 26 | 27 | ALLOWED_SIGNING_ALGORITHMS = ["RS256", "RS384", "RS512"] 28 | 29 | AUTHORIZED_PARTY = "azp" 30 | AUDIENCE_CLAIM = "aud" 31 | ISSUER_CLAIM = "iss" 32 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/Dockerfile_model_runtime: -------------------------------------------------------------------------------- 1 | # https://github.com/tornadoweb/tornado/blob/master/demos/blog/Dockerfile 2 | FROM python:3.6 3 | 4 | # Port the model runtime service will listen on. 5 | EXPOSE 8880 6 | 7 | # Make structure where the models will live. 8 | RUN mkdir -p /cognitiveModels/bert 9 | RUN mkdir -p /cognitiveModels/bidaf 10 | 11 | # Copy and install models. 12 | COPY model /model/ 13 | #RUN pip3 install --upgrade pip 14 | #RUN pip3 install --upgrade nltk 15 | RUN wget https://files.pythonhosted.org/packages/69/60/f685fb2cfb3088736bafbc9bdbb455327bdc8906b606da9c9a81bae1c81e/torch-1.1.0-cp36-cp36m-manylinux1_x86_64.whl 16 | RUN pip3 install torch-1.1.0-cp36-cp36m-manylinux1_x86_64.whl 17 | RUN pip3 install -e /model 18 | 19 | # Copy and install model runtime service api. 20 | COPY model_runtime_svc /model_runtime_svc/ 21 | RUN pip3 install -e /model_runtime_svc 22 | 23 | # One time initialization of the models. 24 | RUN python3 /model_runtime_svc/model_runtime_svc_corebot101/docker_init.py 25 | RUN rm /model_runtime_svc/model_runtime_svc_corebot101/docker_init.py 26 | 27 | WORKDIR /model_runtime_svc 28 | 29 | ENTRYPOINT ["python3", "./model_runtime_svc_corebot101/main.py"] -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Python cache 2 | __pycache__/ 3 | *.pyc 4 | 5 | # Virtual environment 6 | env*/ 7 | venv*/ 8 | 9 | # PTVS analysis 10 | .ptvs/ 11 | 12 | # Coverage report 13 | **/.coverage 14 | 15 | # Build results 16 | bin/ 17 | obj/ 18 | dist/ 19 | MANIFEST 20 | 21 | # Result of running python setup.py install/pip install -e 22 | RECORD.txt 23 | build/ 24 | *.egg-info/ 25 | 26 | # Test results 27 | TestResults/ 28 | .pytest_cache 29 | 30 | # Credentials 31 | credentials_real.json 32 | testsettings_local.json 33 | testsettings_local.cfg 34 | servicebus_settings_real.py 35 | storage_settings_real.py 36 | legacy_mgmt_settings_real.py 37 | mgmt_settings_real.py 38 | app_creds_real.py 39 | 40 | # User-specific files 41 | *.suo 42 | *.user 43 | *.sln.docstates 44 | .vs/ 45 | .vscode 46 | 47 | # Windows image file caches 48 | Thumbs.db 49 | ehthumbs.db 50 | 51 | # Folder config file 52 | Desktop.ini 53 | 54 | # Recycle Bin used on file shares 55 | $RECYCLE.BIN/ 56 | 57 | # Mac desktop service store files 58 | .DS_Store 59 | 60 | .idea 61 | src/build 62 | *.iml 63 | /doc/_build 64 | /.vs/config/applicationhost.config 65 | 66 | # Azure deployment credentials 67 | *.pubxml 68 | 69 | # [begoldsm] ignore virtual env if it exists. 70 | adlEnv/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/models/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # -------------------------------------------------------------------------- 7 | 8 | from .feedback_record import FeedbackRecord 9 | from .feedback_records import FeedbackRecords 10 | from .generate_answer_request_body import GenerateAnswerRequestBody 11 | from .metadata import Metadata 12 | from .prompt import Prompt 13 | from .qnamaker_trace_info import QnAMakerTraceInfo 14 | from .qna_request_context import QnARequestContext 15 | from .qna_response_context import QnAResponseContext 16 | from .query_result import QueryResult 17 | from .query_results import QueryResults 18 | from .train_request_body import TrainRequestBody 19 | 20 | __all__ = [ 21 | "FeedbackRecord", 22 | "FeedbackRecords", 23 | "GenerateAnswerRequestBody", 24 | "Metadata", 25 | "Prompt", 26 | "QnAMakerTraceInfo", 27 | "QnARequestContext", 28 | "QnAResponseContext", 29 | "QueryResult", 30 | "QueryResults", 31 | "TrainRequestBody", 32 | ] 33 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/inspection/inspection_session.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import Any 5 | 6 | from botbuilder.core import TurnContext 7 | from botbuilder.schema import Activity, ConversationReference 8 | from botframework.connector.aio import ConnectorClient 9 | from botframework.connector.auth import MicrosoftAppCredentials 10 | 11 | 12 | class InspectionSession: 13 | def __init__( 14 | self, 15 | conversation_reference: ConversationReference, 16 | credentials: MicrosoftAppCredentials, 17 | ): 18 | self._conversation_reference = conversation_reference 19 | self._connector_client = ConnectorClient( 20 | credentials, base_url=conversation_reference.service_url 21 | ) 22 | 23 | async def send(self, activity: Activity) -> Any: 24 | TurnContext.apply_conversation_reference(activity, self._conversation_reference) 25 | 26 | try: 27 | await self._connector_client.conversations.send_to_conversation( 28 | activity.conversation.id, activity 29 | ) 30 | except Exception: 31 | return False 32 | 33 | return True 34 | -------------------------------------------------------------------------------- /Generator/generator-botbuilder-python/generators/app/templates/README.md: -------------------------------------------------------------------------------- 1 | # <%= botName %> Bot 2 | 3 | This bot has been created using [Microsoft Bot Framework](https://dev.botframework.com), 4 | 5 | This bot is designed to do the following: 6 | 7 | <%= description %> 8 | 9 | ## About the generator 10 | 11 | The goal of the BotBuilder Yeoman generator is to both scaffold out a bot according to general best practices, and to provide some templates you can use when implementing commonly requested features and dialogs in your bot. 12 | 13 | One thing to note is it's not possible to completely generate a bot or dialog, as the questions you need to ask of your user will vary wildly depending on your scenario. As such, we hope we've given you a good starting point for building your bots with Bot Framework. 14 | 15 | ## Getting Started 16 | 17 | ### Dependencies 18 | 19 | ### Structure 20 | 21 | ### Configuring the bot 22 | 23 | - Echo dialog is designed for simple Hello, World demos and to get you started. 24 | 25 | ### Running the bot 26 | 27 | ## Additional Resources 28 | 29 | - [Microsoft Virtual Academy Bots Course](http://aka.ms/botcourse) 30 | - [Bot Framework Documentation](https://docs.botframework.com) 31 | - [LUIS](https://luis.ai) 32 | - [QnA Maker](https://qnamaker.ai) -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/recordings/test_conversations_get_conversation_members_invalid_id_fails.yaml: -------------------------------------------------------------------------------- 1 | interactions: 2 | - request: 3 | body: null 4 | headers: 5 | Accept: [application/json] 6 | Accept-Encoding: ['gzip, deflate'] 7 | Connection: [keep-alive] 8 | Content-Type: [application/json; charset=utf-8] 9 | User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.1 msrest/0.4.23 10 | azure-botframework-connector/3.0] 11 | method: GET 12 | uri: https://slack.botframework.com/v3/conversations/INVALID_ID/members 13 | response: 14 | body: {string: "{\r\n \"error\": {\r\n \"code\": \"ServiceError\",\r\n \ 15 | \ \"message\": \"Invalid ConversationId: INVALID_ID\"\r\n }\r\n}"} 16 | headers: 17 | cache-control: [no-cache] 18 | content-length: ['105'] 19 | content-type: [application/json; charset=utf-8] 20 | date: ['Fri, 29 Dec 2017 15:38:35 GMT'] 21 | expires: ['-1'] 22 | pragma: [no-cache] 23 | request-context: ['appId=cid-v1:6814484e-c0d5-40ea-9dba-74ff29ca4f62'] 24 | server: [Microsoft-IIS/10.0] 25 | strict-transport-security: [max-age=31536000] 26 | x-powered-by: [ASP.NET] 27 | status: {code: 400, message: Bad Request} 28 | version: 1 29 | -------------------------------------------------------------------------------- /samples/13.core-bot/helpers/activity_helper.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from datetime import datetime 5 | from botbuilder.schema import ( 6 | Activity, 7 | ActivityTypes, 8 | ChannelAccount, 9 | ConversationAccount, 10 | ) 11 | 12 | 13 | def create_activity_reply(activity: Activity, text: str = None, locale: str = None): 14 | 15 | return Activity( 16 | type=ActivityTypes.message, 17 | timestamp=datetime.utcnow(), 18 | from_property=ChannelAccount( 19 | id=getattr(activity.recipient, "id", None), 20 | name=getattr(activity.recipient, "name", None), 21 | ), 22 | recipient=ChannelAccount( 23 | id=activity.from_property.id, name=activity.from_property.name 24 | ), 25 | reply_to_id=activity.id, 26 | service_url=activity.service_url, 27 | channel_id=activity.channel_id, 28 | conversation=ConversationAccount( 29 | is_group=activity.conversation.is_group, 30 | id=activity.conversation.id, 31 | name=activity.conversation.name, 32 | ), 33 | text=text or "", 34 | locale=locale or "", 35 | attachments=[], 36 | entities=[], 37 | ) 38 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/luis/test_data/MultipleIntents_PrebuiltEntity.json: -------------------------------------------------------------------------------- 1 | { 2 | "query": "Please deliver February 2nd 2001", 3 | "topScoringIntent": { 4 | "intent": "Delivery", 5 | "score": 0.8785189 6 | }, 7 | "intents": [ 8 | { 9 | "intent": "Delivery", 10 | "score": 0.8785189 11 | }, 12 | { 13 | "intent": "SpecifyName", 14 | "score": 0.0085189 15 | } 16 | ], 17 | "entities": [ 18 | { 19 | "entity": 2001, 20 | "type": "number", 21 | "startIndex": 28, 22 | "endIndex": 31 23 | }, 24 | { 25 | "entity": 2, 26 | "type": "ordinal", 27 | "startIndex": 24, 28 | "endIndex": 26 29 | }, 30 | { 31 | "entity": "february 2nd 2001", 32 | "type": "builtin.datetimeV2.date", 33 | "startIndex": 15, 34 | "endIndex": 31, 35 | "resolution": { 36 | "values": [ 37 | { 38 | "timex": "2001-02-02", 39 | "type": "date", 40 | "value": "2001-02-02" 41 | } 42 | ] 43 | } 44 | } 45 | ] 46 | } -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/botbuilder/applicationinsights/bot_telemetry_processor.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Application Insights Telemetry Processor for Bots.""" 4 | from typing import List 5 | 6 | from .django.django_telemetry_processor import DjangoTelemetryProcessor 7 | from .flask.flask_telemetry_processor import FlaskTelemetryProcessor 8 | from .processor.telemetry_processor import TelemetryProcessor 9 | 10 | 11 | class BotTelemetryProcessor(TelemetryProcessor): 12 | """Application Insights Telemetry Processor for Bot""" 13 | 14 | def __init__(self, processors: List[TelemetryProcessor] = None): 15 | self._processors: List[TelemetryProcessor] = [ 16 | DjangoTelemetryProcessor(), 17 | FlaskTelemetryProcessor(), 18 | ] if processors is None else processors 19 | 20 | def can_process(self) -> bool: 21 | for processor in self._processors: 22 | if processor.can_process(): 23 | return True 24 | 25 | return False 26 | 27 | def get_request_body(self) -> str: 28 | for inner in self._processors: 29 | if inner.can_process(): 30 | return inner.get_request_body() 31 | 32 | return super().get_request_body() 33 | -------------------------------------------------------------------------------- /samples/13.core-bot/flight_booking_recognizer.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from botbuilder.ai.luis import LuisApplication, LuisRecognizer 5 | from botbuilder.core import Recognizer, RecognizerResult, TurnContext 6 | 7 | 8 | class FlightBookingRecognizer(Recognizer): 9 | def __init__(self, configuration: dict): 10 | self._recognizer = None 11 | 12 | luis_is_configured = ( 13 | configuration["LUIS_APP_ID"] 14 | and configuration["LUIS_API_KEY"] 15 | and configuration["LUIS_API_HOST_NAME"] 16 | ) 17 | if luis_is_configured: 18 | luis_application = LuisApplication( 19 | configuration["LUIS_APP_ID"], 20 | configuration["LUIS_API_KEY"], 21 | "https://" + configuration["LUIS_API_HOST_NAME"], 22 | ) 23 | 24 | self._recognizer = LuisRecognizer(luis_application) 25 | 26 | @property 27 | def is_configured(self) -> bool: 28 | # Returns true if luis is configured in the appsettings.json and initialized. 29 | return self._recognizer is not None 30 | 31 | async def recognize(self, turn_context: TurnContext) -> RecognizerResult: 32 | return await self._recognizer.recognize(turn_context) 33 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/qna/models/prompt.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from msrest.serialization import Model 5 | 6 | 7 | class Prompt(Model): 8 | """ Prompt Object. """ 9 | 10 | _attribute_map = { 11 | "display_order": {"key": "displayOrder", "type": "int"}, 12 | "qna_id": {"key": "qnaId", "type": "int"}, 13 | "qna": {"key": "qna", "type": "object"}, 14 | "display_text": {"key": "displayText", "type": "str"}, 15 | } 16 | 17 | def __init__( 18 | self, 19 | *, 20 | display_order: int, 21 | qna_id: int, 22 | display_text: str, 23 | qna: object = None, 24 | **kwargs 25 | ): 26 | """ 27 | Parameters: 28 | ----------- 29 | 30 | display_order: Index of the prompt - used in ordering of the prompts. 31 | 32 | qna_id: QnA ID. 33 | 34 | display_text: Text displayed to represent a follow up question prompt. 35 | 36 | qna: The QnA object returned from the API (Optional). 37 | 38 | """ 39 | 40 | super(Prompt, self).__init__(**kwargs) 41 | 42 | self.display_order = display_order 43 | self.qna_id = qna_id 44 | self.display_text = display_text 45 | self.qna = qna 46 | -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/recordings/test_conversations_delete_activity_with_invalid_conversation_id_fails.yaml: -------------------------------------------------------------------------------- 1 | interactions: 2 | - request: 3 | body: null 4 | headers: 5 | Accept: [application/json] 6 | Accept-Encoding: ['gzip, deflate'] 7 | Connection: [keep-alive] 8 | Content-Length: ['0'] 9 | Content-Type: [application/json; charset=utf-8] 10 | User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.1 msrest/0.4.23 11 | azure-botframework-connector/3.0] 12 | method: DELETE 13 | uri: https://slack.botframework.com/v3/conversations/INVALID_ID/activities/INVALID_ID 14 | response: 15 | body: {string: "{\r\n \"error\": {\r\n \"code\": \"ServiceError\",\r\n \ 16 | \ \"message\": \"Invalid ConversationId: INVALID_ID\"\r\n }\r\n}"} 17 | headers: 18 | cache-control: [no-cache] 19 | content-length: ['105'] 20 | content-type: [application/json; charset=utf-8] 21 | date: ['Fri, 29 Dec 2017 18:07:23 GMT'] 22 | expires: ['-1'] 23 | pragma: [no-cache] 24 | request-context: ['appId=cid-v1:6814484e-c0d5-40ea-9dba-74ff29ca4f62'] 25 | server: [Microsoft-IIS/10.0] 26 | strict-transport-security: [max-age=31536000] 27 | x-powered-by: [ASP.NET] 28 | status: {code: 400, message: Bad Request} 29 | version: 1 30 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/choices/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # -------------------------------------------------------------------------- 7 | 8 | from .channel import Channel 9 | from .choice import Choice 10 | from .choice_factory_options import ChoiceFactoryOptions 11 | from .choice_factory import ChoiceFactory 12 | from .choice_recognizers import ChoiceRecognizers 13 | from .find import Find 14 | from .find_choices_options import FindChoicesOptions, FindValuesOptions 15 | from .found_choice import FoundChoice 16 | from .found_value import FoundValue 17 | from .list_style import ListStyle 18 | from .model_result import ModelResult 19 | from .sorted_value import SortedValue 20 | from .token import Token 21 | from .tokenizer import Tokenizer 22 | 23 | __all__ = [ 24 | "Channel", 25 | "Choice", 26 | "ChoiceFactory", 27 | "ChoiceFactoryOptions", 28 | "ChoiceRecognizers", 29 | "Find", 30 | "FindChoicesOptions", 31 | "FindValuesOptions", 32 | "FoundChoice", 33 | "ListStyle", 34 | "ModelResult", 35 | "SortedValue", 36 | "Token", 37 | "Tokenizer", 38 | ] 39 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/channels.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from enum import Enum 5 | 6 | 7 | class Channels(str, Enum): 8 | """ 9 | Ids of channels supported by the Bot Builder. 10 | """ 11 | 12 | console = "console" 13 | """Console channel.""" 14 | 15 | cortana = "cortana" 16 | """Cortana channel.""" 17 | 18 | direct_line = "directline" 19 | """Direct Line channel.""" 20 | 21 | email = "email" 22 | """Email channel.""" 23 | 24 | emulator = "emulator" 25 | """Emulator channel.""" 26 | 27 | facebook = "facebook" 28 | """Facebook channel.""" 29 | 30 | groupme = "groupme" 31 | """Group Me channel.""" 32 | 33 | kik = "kik" 34 | """Kik channel.""" 35 | 36 | line = "line" 37 | """Line channel.""" 38 | 39 | ms_teams = "msteams" 40 | """MS Teams channel.""" 41 | 42 | skype = "skype" 43 | """Skype channel.""" 44 | 45 | skype_for_business = "skypeforbusiness" 46 | """Skype for Business channel.""" 47 | 48 | slack = "slack" 49 | """Slack channel.""" 50 | 51 | sms = "sms" 52 | """SMS (Twilio) channel.""" 53 | 54 | telegram = "telegram" 55 | """Telegram channel.""" 56 | 57 | webchat = "webchat" 58 | """WebChat channel.""" 59 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/luis/telemetry_override_recognizer.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import Dict 5 | 6 | from botbuilder.ai.luis import LuisRecognizer, LuisTelemetryConstants 7 | from botbuilder.core import RecognizerResult, TurnContext 8 | 9 | 10 | class TelemetryOverrideRecognizer(LuisRecognizer): 11 | def __init__(self, *args, **kwargs): 12 | super(TelemetryOverrideRecognizer, self).__init__(*args, **kwargs) 13 | 14 | def on_recognizer_result( 15 | self, 16 | recognizer_result: RecognizerResult, 17 | turn_context: TurnContext, 18 | telemetry_properties: Dict[str, str] = None, 19 | telemetry_metrics: Dict[str, float] = None, 20 | ): 21 | if "MyImportantProperty" not in telemetry_properties: 22 | telemetry_properties["MyImportantProperty"] = "myImportantValue" 23 | 24 | # Log event 25 | self.telemetry_client.track_event( 26 | LuisTelemetryConstants.luis_result, telemetry_properties, telemetry_metrics 27 | ) 28 | 29 | # Create second event. 30 | second_event_properties: Dict[str, str] = { 31 | "MyImportantProperty2": "myImportantValue2" 32 | } 33 | self.telemetry_client.track_event("MySecondEvent", second_event_properties) 34 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/qna/test_data/AnswerWithOptions.json: -------------------------------------------------------------------------------- 1 | { 2 | "answers": [ 3 | { 4 | "questions": [ 5 | "up" 6 | ], 7 | "answer": "is a movie", 8 | "score": 100, 9 | "id": 3, 10 | "source": "Editorial", 11 | "metadata": [ 12 | { 13 | "name": "movie", 14 | "value": "disney" 15 | } 16 | ] 17 | }, 18 | { 19 | "questions": [ 20 | "up" 21 | ], 22 | "answer": "2nd answer", 23 | "score": 100, 24 | "id": 4, 25 | "source": "Editorial", 26 | "metadata": [ 27 | { 28 | "name": "movie", 29 | "value": "disney" 30 | } 31 | ] 32 | }, 33 | { 34 | "questions": [ 35 | "up" 36 | ], 37 | "answer": "3rd answer", 38 | "score": 100, 39 | "id": 5, 40 | "source": "Editorial", 41 | "metadata": [ 42 | { 43 | "name": "movie", 44 | "value": "disney" 45 | } 46 | ] 47 | } 48 | ], 49 | "debugInfo": null 50 | } -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/state_property_accessor.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from abc import ABC, abstractmethod 5 | 6 | from .turn_context import TurnContext 7 | 8 | 9 | class StatePropertyAccessor(ABC): 10 | @abstractmethod 11 | async def get( 12 | self, turn_context: TurnContext, default_value_or_factory=None 13 | ) -> object: 14 | """ 15 | Get the property value from the source 16 | :param turn_context: Turn Context. 17 | :param default_value_or_factory: Function which defines the property 18 | value to be returned if no value has been set. 19 | 20 | :return: 21 | """ 22 | raise NotImplementedError() 23 | 24 | @abstractmethod 25 | async def delete(self, turn_context: TurnContext) -> None: 26 | """ 27 | Saves store items to storage. 28 | :param turn_context: Turn Context. 29 | :return: 30 | """ 31 | raise NotImplementedError() 32 | 33 | @abstractmethod 34 | async def set(self, turn_context: TurnContext, value) -> None: 35 | """ 36 | Set the property value on the source. 37 | :param turn_context: Turn Context. 38 | :param value: 39 | :return: 40 | """ 41 | raise NotImplementedError() 42 | -------------------------------------------------------------------------------- /libraries/botbuilder-schema/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | from setuptools import setup 6 | 7 | NAME = "botbuilder-schema" 8 | VERSION = os.environ["packageVersion"] if "packageVersion" in os.environ else "4.4.0b1" 9 | REQUIRES = ["msrest>=0.6.6"] 10 | 11 | root = os.path.abspath(os.path.dirname(__file__)) 12 | 13 | with open(os.path.join(root, "README.rst"), encoding="utf-8") as f: 14 | long_description = f.read() 15 | 16 | setup( 17 | name=NAME, 18 | version=VERSION, 19 | description="BotBuilder Schema", 20 | author="Microsoft", 21 | url="https://github.com/Microsoft/botbuilder-python", 22 | keywords=["BotBuilderSchema", "bots", "ai", "botframework", "botbuilder"], 23 | long_description=long_description, 24 | long_description_content_type="text/x-rst", 25 | license="MIT", 26 | install_requires=REQUIRES, 27 | packages=["botbuilder.schema"], 28 | include_package_data=True, 29 | classifiers=[ 30 | "Programming Language :: Python :: 3.7", 31 | "Intended Audience :: Developers", 32 | "License :: OSI Approved :: MIT License", 33 | "Operating System :: OS Independent", 34 | "Development Status :: 3 - Alpha", 35 | "Topic :: Scientific/Engineering :: Artificial Intelligence", 36 | ], 37 | ) 38 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/choices/choice_factory_options.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | 5 | class ChoiceFactoryOptions: 6 | def __init__( 7 | self, 8 | inline_separator: str = None, 9 | inline_or: str = None, 10 | inline_or_more: str = None, 11 | include_numbers: bool = None, 12 | ) -> None: 13 | """Initializes a new instance. 14 | Refer to the code in the ConfirmPrompt for an example of usage. 15 | 16 | :param object: 17 | :type object: 18 | :param inline_separator: The inline seperator value, defaults to None 19 | :param inline_separator: str, optional 20 | :param inline_or: The inline or value, defaults to None 21 | :param inline_or: str, optional 22 | :param inline_or_more: The inline or more value, defaults to None 23 | :param inline_or_more: str, optional 24 | :param includeNumbers: Flag indicating whether to include numbers as a choice, defaults to None 25 | :param includeNumbers: bool, optional 26 | :return: 27 | :rtype: None 28 | """ 29 | 30 | self.inline_separator = inline_separator 31 | self.inline_or = inline_or 32 | self.inline_or_more = inline_or_more 33 | self.include_numbers = include_numbers 34 | -------------------------------------------------------------------------------- /samples/python_django/13.core-bot/helpers/activity_helper.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Helper to create reply object.""" 4 | 5 | from datetime import datetime 6 | from botbuilder.schema import ( 7 | Activity, 8 | ActivityTypes, 9 | ChannelAccount, 10 | ConversationAccount, 11 | ) 12 | 13 | 14 | def create_activity_reply(activity: Activity, text: str = None, locale: str = None): 15 | """Helper to create reply object.""" 16 | return Activity( 17 | type=ActivityTypes.message, 18 | timestamp=datetime.utcnow(), 19 | from_property=ChannelAccount( 20 | id=getattr(activity.recipient, "id", None), 21 | name=getattr(activity.recipient, "name", None), 22 | ), 23 | recipient=ChannelAccount( 24 | id=activity.from_property.id, name=activity.from_property.name 25 | ), 26 | reply_to_id=activity.id, 27 | service_url=activity.service_url, 28 | channel_id=activity.channel_id, 29 | conversation=ConversationAccount( 30 | is_group=activity.conversation.is_group, 31 | id=activity.conversation.id, 32 | name=activity.conversation.name, 33 | ), 34 | text=text or "", 35 | locale=locale or "", 36 | attachments=[], 37 | entities=[], 38 | ) 39 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/token_api/models/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # 7 | # Code generated by Microsoft (R) AutoRest Code Generator. 8 | # Changes may cause incorrect behavior and will be lost if the code is 9 | # regenerated. 10 | # -------------------------------------------------------------------------- 11 | 12 | try: 13 | from ._models_py3 import AadResourceUrls 14 | from ._models_py3 import Error 15 | from ._models_py3 import ErrorResponse, ErrorResponseException 16 | from ._models_py3 import InnerHttpError 17 | from ._models_py3 import TokenResponse 18 | from ._models_py3 import TokenStatus 19 | except (SyntaxError, ImportError): 20 | from ._models import AadResourceUrls 21 | from ._models import Error 22 | from ._models import ErrorResponse, ErrorResponseException 23 | from ._models import InnerHttpError 24 | from ._models import TokenResponse 25 | from ._models import TokenStatus 26 | 27 | __all__ = [ 28 | "AadResourceUrls", 29 | "Error", 30 | "ErrorResponse", 31 | "ErrorResponseException", 32 | "InnerHttpError", 33 | "TokenResponse", 34 | "TokenStatus", 35 | ] 36 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/conversation_state.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from .turn_context import TurnContext 5 | from .bot_state import BotState 6 | from .storage import Storage 7 | 8 | 9 | class ConversationState(BotState): 10 | """Conversation State 11 | Reads and writes conversation state for your bot to storage. 12 | """ 13 | 14 | no_key_error_message = "ConversationState: channelId and/or conversation missing from context.activity." 15 | 16 | def __init__(self, storage: Storage): 17 | super(ConversationState, self).__init__(storage, "ConversationState") 18 | 19 | def get_storage_key(self, turn_context: TurnContext) -> object: 20 | channel_id = turn_context.activity.channel_id or self.__raise_type_error( 21 | "invalid activity-missing channel_id" 22 | ) 23 | conversation_id = ( 24 | turn_context.activity.conversation.id 25 | or self.__raise_type_error("invalid activity-missing conversation.id") 26 | ) 27 | 28 | storage_key = None 29 | if channel_id and conversation_id: 30 | storage_key = "%s/conversations/%s" % (channel_id, conversation_id) 31 | return storage_key 32 | 33 | def __raise_type_error(self, err: str = "NoneType found while expecting value"): 34 | raise TypeError(err) 35 | -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/recordings/test_conversations_get_conversation_members.yaml: -------------------------------------------------------------------------------- 1 | interactions: 2 | - request: 3 | body: null 4 | headers: 5 | Accept: [application/json] 6 | Accept-Encoding: ['gzip, deflate'] 7 | Connection: [keep-alive] 8 | Content-Type: [application/json; charset=utf-8] 9 | User-Agent: [python/3.5.3 (Linux-4.11.0-041100-generic-x86_64-with-Ubuntu-17.04-zesty) 10 | requests/2.18.1 msrest/0.4.23 azure-botframework-connector/v3.0] 11 | method: GET 12 | uri: https://slack.botframework.com/v3/conversations/B21UTEF8S%3AT03CWQ0QB%3AD2369CT7C/members 13 | response: 14 | body: {string: "[\r\n {\r\n \"id\": \"B21UTEF8S:T03CWQ0QB\",\r\n \"name\"\ 15 | : \"botbuilder-pc-bot\"\r\n },\r\n {\r\n \"id\": \"U19KH8EHJ:T03CWQ0QB\"\ 16 | ,\r\n \"name\": \"pc\"\r\n }\r\n]"} 17 | headers: 18 | cache-control: [no-cache] 19 | content-length: ['144'] 20 | content-type: [application/json; charset=utf-8] 21 | date: ['Tue, 26 Dec 2017 13:51:30 GMT'] 22 | expires: ['-1'] 23 | pragma: [no-cache] 24 | request-context: ['appId=cid-v1:6814484e-c0d5-40ea-9dba-74ff29ca4f62'] 25 | server: [Microsoft-IIS/10.0] 26 | strict-transport-security: [max-age=31536000] 27 | vary: [Accept-Encoding] 28 | x-powered-by: [ASP.NET] 29 | status: {code: 200, message: OK} 30 | version: 1 31 | -------------------------------------------------------------------------------- /samples/21.corebot-app-insights/helpers/activity_helper.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Helper to create reply object.""" 4 | 5 | from datetime import datetime 6 | from botbuilder.schema import ( 7 | Activity, 8 | ActivityTypes, 9 | ChannelAccount, 10 | ConversationAccount, 11 | ) 12 | 13 | 14 | def create_activity_reply(activity: Activity, text: str = None, locale: str = None): 15 | """Helper to create reply object.""" 16 | return Activity( 17 | type=ActivityTypes.message, 18 | timestamp=datetime.utcnow(), 19 | from_property=ChannelAccount( 20 | id=getattr(activity.recipient, "id", None), 21 | name=getattr(activity.recipient, "name", None), 22 | ), 23 | recipient=ChannelAccount( 24 | id=activity.from_property.id, name=activity.from_property.name 25 | ), 26 | reply_to_id=activity.id, 27 | service_url=activity.service_url, 28 | channel_id=activity.channel_id, 29 | conversation=ConversationAccount( 30 | is_group=activity.conversation.is_group, 31 | id=activity.conversation.id, 32 | name=activity.conversation.name, 33 | ), 34 | text=text or "", 35 | locale=locale or "", 36 | attachments=[], 37 | entities=[], 38 | ) 39 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/qna/test_data/TopNAnswer.json: -------------------------------------------------------------------------------- 1 | { 2 | "answers": [ 3 | { 4 | "questions": [ 5 | "Q1" 6 | ], 7 | "answer": "A1", 8 | "score": 80, 9 | "id": 15, 10 | "source": "Editorial", 11 | "metadata": [ 12 | { 13 | "name": "topic", 14 | "value": "value" 15 | } 16 | ] 17 | }, 18 | { 19 | "questions": [ 20 | "Q2" 21 | ], 22 | "answer": "A2", 23 | "score": 78, 24 | "id": 16, 25 | "source": "Editorial", 26 | "metadata": [ 27 | { 28 | "name": "topic", 29 | "value": "value" 30 | } 31 | ] 32 | }, 33 | { 34 | "questions": [ 35 | "Q3" 36 | ], 37 | "answer": "A3", 38 | "score": 75, 39 | "id": 17, 40 | "source": "Editorial", 41 | "metadata": [ 42 | { 43 | "name": "topic", 44 | "value": "value" 45 | } 46 | ] 47 | }, 48 | { 49 | "questions": [ 50 | "Q4" 51 | ], 52 | "answer": "A4", 53 | "score": 50, 54 | "id": 18, 55 | "source": "Editorial", 56 | "metadata": [ 57 | { 58 | "name": "topic", 59 | "value": "value" 60 | } 61 | ] 62 | } 63 | ] 64 | } -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/recordings/test_conversations_send_to_conversation.yaml: -------------------------------------------------------------------------------- 1 | interactions: 2 | - request: 3 | body: '{"recipient": {"id": "U19KH8EHJ:T03CWQ0QB"}, "channelId": "slack", "text": 4 | "Hello again!", "from": {"id": "B21UTEF8S:T03CWQ0QB"}, "type": "message"}' 5 | headers: 6 | Accept: [application/json] 7 | Accept-Encoding: ['gzip, deflate'] 8 | Connection: [keep-alive] 9 | Content-Length: ['148'] 10 | Content-Type: [application/json; charset=utf-8] 11 | User-Agent: [python/3.5.3 (Linux-4.11.0-041100-generic-x86_64-with-Ubuntu-17.04-zesty) 12 | requests/2.18.1 msrest/0.4.23 azure-botframework-connector/v3.0] 13 | method: POST 14 | uri: https://slack.botframework.com/v3/conversations/B21UTEF8S%3AT03CWQ0QB%3AD2369CT7C/activities 15 | response: 16 | body: {string: "{\r\n \"id\": \"1514296291.000146\"\r\n}"} 17 | headers: 18 | cache-control: [no-cache] 19 | content-length: ['33'] 20 | content-type: [application/json; charset=utf-8] 21 | date: ['Tue, 26 Dec 2017 13:51:30 GMT'] 22 | expires: ['-1'] 23 | pragma: [no-cache] 24 | request-context: ['appId=cid-v1:6814484e-c0d5-40ea-9dba-74ff29ca4f62'] 25 | server: [Microsoft-IIS/10.0] 26 | strict-transport-security: [max-age=31536000] 27 | vary: [Accept-Encoding] 28 | x-powered-by: [ASP.NET] 29 | status: {code: 200, message: OK} 30 | version: 1 31 | -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/bot/helpers/activity_helper.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | """Helper to create reply object.""" 4 | 5 | from datetime import datetime 6 | from botbuilder.schema import ( 7 | Activity, 8 | ActivityTypes, 9 | ChannelAccount, 10 | ConversationAccount, 11 | ) 12 | 13 | 14 | def create_activity_reply(activity: Activity, text: str = None, locale: str = None): 15 | """Helper to create reply object.""" 16 | return Activity( 17 | type=ActivityTypes.message, 18 | timestamp=datetime.utcnow(), 19 | from_property=ChannelAccount( 20 | id=getattr(activity.recipient, "id", None), 21 | name=getattr(activity.recipient, "name", None), 22 | ), 23 | recipient=ChannelAccount( 24 | id=activity.from_property.id, name=activity.from_property.name 25 | ), 26 | reply_to_id=activity.id, 27 | service_url=activity.service_url, 28 | channel_id=activity.channel_id, 29 | conversation=ConversationAccount( 30 | is_group=activity.conversation.is_group, 31 | id=activity.conversation.id, 32 | name=activity.conversation.name, 33 | ), 34 | text=text or "", 35 | locale=locale or "", 36 | attachments=[], 37 | entities=[], 38 | ) 39 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/botbuilder/ai/luis/luis_prediction_options.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft. All rights reserved. 2 | # Licensed under the MIT license. 3 | 4 | from botbuilder.core import BotTelemetryClient, NullTelemetryClient 5 | 6 | 7 | class LuisPredictionOptions: 8 | """ 9 | Optional parameters for a LUIS prediction request. 10 | """ 11 | 12 | def __init__( 13 | self, 14 | bing_spell_check_subscription_key: str = None, 15 | include_all_intents: bool = None, 16 | include_instance_data: bool = None, 17 | log: bool = None, 18 | spell_check: bool = None, 19 | staging: bool = None, 20 | timeout: float = 100000, 21 | timezone_offset: float = None, 22 | telemetry_client: BotTelemetryClient = NullTelemetryClient(), 23 | log_personal_information: bool = False, 24 | ): 25 | self.bing_spell_check_subscription_key: str = bing_spell_check_subscription_key 26 | self.include_all_intents: bool = include_all_intents 27 | self.include_instance_data: bool = include_instance_data 28 | self.log: bool = log 29 | self.spell_check: bool = spell_check 30 | self.staging: bool = staging 31 | self.timeout: float = timeout 32 | self.timezone_offset: float = timezone_offset 33 | self.telemetry_client: BotTelemetryClient = telemetry_client 34 | self.log_personal_information: bool = log_personal_information 35 | -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/tests/choices/test_choice_factory_options.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import unittest 5 | 6 | from botbuilder.dialogs.choices import ChoiceFactoryOptions 7 | 8 | 9 | class ChoiceFactoryOptionsTest(unittest.TestCase): 10 | def test_inline_separator_round_trips(self) -> None: 11 | choice_factor_options = ChoiceFactoryOptions() 12 | expected = ", " 13 | choice_factor_options.inline_separator = expected 14 | self.assertEqual(expected, choice_factor_options.inline_separator) 15 | 16 | def test_inline_or_round_trips(self) -> None: 17 | choice_factor_options = ChoiceFactoryOptions() 18 | expected = " or " 19 | choice_factor_options.inline_or = expected 20 | self.assertEqual(expected, choice_factor_options.inline_or) 21 | 22 | def test_inline_or_more_round_trips(self) -> None: 23 | choice_factor_options = ChoiceFactoryOptions() 24 | expected = ", or " 25 | choice_factor_options.inline_or_more = expected 26 | self.assertEqual(expected, choice_factor_options.inline_or_more) 27 | 28 | def test_include_numbers_round_trips(self) -> None: 29 | choice_factor_options = ChoiceFactoryOptions() 30 | expected = True 31 | choice_factor_options.include_numbers = expected 32 | self.assertEqual(expected, choice_factor_options.include_numbers) 33 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/auth/endorsements_validator.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import List 5 | 6 | 7 | class EndorsementsValidator: 8 | @staticmethod 9 | def validate(channel_id: str, endorsements: List[str]): 10 | # If the Activity came in and doesn't have a Channel ID then it's making no 11 | # assertions as to who endorses it. This means it should pass. 12 | if not channel_id: 13 | return True 14 | 15 | if endorsements is None: 16 | raise ValueError("Argument endorsements is null.") 17 | 18 | # The Call path to get here is: 19 | # JwtTokenValidation.AuthenticateRequest 20 | # -> 21 | # JwtTokenValidation.ValidateAuthHeader 22 | # -> 23 | # ChannelValidation.AuthenticateChannelToken 24 | # -> 25 | # JWTTokenExtractor 26 | 27 | # Does the set of endorsements match the channelId that was passed in? 28 | 29 | # ToDo: Consider moving this to a HashSet instead of a string 30 | # array, to make lookups O(1) instead of O(N). To give a sense 31 | # of scope, tokens from WebChat have about 10 endorsements, and 32 | # tokens coming from Teams have about 20. 33 | 34 | endorsement_present = channel_id in endorsements 35 | return endorsement_present 36 | -------------------------------------------------------------------------------- /libraries/botbuilder-applicationinsights/django_tests/all_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) Microsoft Corporation. All rights reserved. 3 | # Licensed under the MIT License. 4 | 5 | if [ -z $PYTHON ]; then 6 | PYTHON=$(which python) 7 | fi 8 | 9 | cd $(dirname $0) 10 | BASEDIR=$(pwd) 11 | 12 | # Django/python compatibility matrix... 13 | if $PYTHON -c "import sys; sys.exit(1 if (sys.version_info.major == 3 and sys.version_info.minor == 6) else 0)"; then 14 | echo "[Error] Environment should be configured with Python 3.7!" 1>&2 15 | exit 2 16 | fi 17 | # Add more versions here (space delimited). 18 | DJANGO_VERSIONS='2.2' 19 | 20 | # For each Django version... 21 | for v in $DJANGO_VERSIONS 22 | do 23 | echo "" 24 | echo "***" 25 | echo "*** Running tests for Django $v" 26 | echo "***" 27 | echo "" 28 | 29 | # Create new directory 30 | TMPDIR=$(mktemp -d) 31 | function cleanup 32 | { 33 | rm -rf $TMPDIR 34 | exit $1 35 | } 36 | 37 | trap cleanup EXIT SIGINT 38 | 39 | # Create virtual environment 40 | $PYTHON -m venv $TMPDIR/env 41 | 42 | # Install Django version + application insights 43 | . $TMPDIR/env/bin/activate 44 | pip install Django==$v || exit $? 45 | cd $BASEDIR/.. 46 | pip install . || exit $? 47 | 48 | # Run tests 49 | cd $BASEDIR 50 | bash ./run_test.sh || exit $? 51 | 52 | # Deactivate 53 | # (Windows may complain since doesn't add deactivate to path properly) 54 | deactivate 55 | 56 | # Remove venv 57 | rm -rf $TMPDIR 58 | done -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/recordings/test_conversations_create_conversation_without_members_fails.yaml: -------------------------------------------------------------------------------- 1 | interactions: 2 | - request: 3 | body: '{"bot": {"id": "B21UTEF8S:T03CWQ0QB"}, "members": [], "activity": {"type": 4 | "message", "channelId": "slack", "from": {"id": "B21UTEF8S:T03CWQ0QB"}, "text": 5 | "Hi there!"}}' 6 | headers: 7 | Accept: [application/json] 8 | Accept-Encoding: ['gzip, deflate'] 9 | Connection: [keep-alive] 10 | Content-Length: ['168'] 11 | Content-Type: [application/json; charset=utf-8] 12 | User-Agent: [python/3.6.4 (Windows-10-10.0.16299-SP0) requests/2.18.1 msrest/0.4.11 13 | bot-connector/v3] 14 | method: POST 15 | uri: https://slack.botframework.com/v3/conversations 16 | response: 17 | body: {string: "{\r\n \"error\": {\r\n \"code\": \"BadArgument\",\r\n \"\ 18 | message\": \"Conversations must be to a single member\"\r\n }\r\n}"} 19 | headers: 20 | cache-control: [no-cache] 21 | content-length: ['110'] 22 | content-type: [application/json; charset=utf-8] 23 | date: ['Thu, 01 Feb 2018 15:20:17 GMT'] 24 | expires: ['-1'] 25 | pragma: [no-cache] 26 | request-context: ['appId=cid-v1:6814484e-c0d5-40ea-9dba-74ff29ca4f62'] 27 | server: [Microsoft-IIS/10.0] 28 | strict-transport-security: [max-age=31536000] 29 | x-powered-by: [ASP.NET] 30 | status: {code: 400, message: Bad Request} 31 | version: 1 32 | -------------------------------------------------------------------------------- /samples/06.using-cards/helpers/activity_helper.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from datetime import datetime 5 | from botbuilder.schema import ( 6 | Activity, 7 | ActivityTypes, 8 | Attachment, 9 | ChannelAccount, 10 | ConversationAccount, 11 | ) 12 | 13 | 14 | def create_activity_reply( 15 | activity: Activity, 16 | text: str = None, 17 | locale: str = None, 18 | attachments: [Attachment] = [], 19 | ): 20 | attachments_aux = [attachment for attachment in attachments] 21 | 22 | return Activity( 23 | type=ActivityTypes.message, 24 | timestamp=datetime.utcnow(), 25 | from_property=ChannelAccount( 26 | id=getattr(activity.recipient, "id", None), 27 | name=getattr(activity.recipient, "name", None), 28 | ), 29 | recipient=ChannelAccount( 30 | id=activity.from_property.id, name=activity.from_property.name 31 | ), 32 | reply_to_id=activity.id, 33 | service_url=activity.service_url, 34 | channel_id=activity.channel_id, 35 | conversation=ConversationAccount( 36 | is_group=activity.conversation.is_group, 37 | id=activity.conversation.id, 38 | name=activity.conversation.name, 39 | ), 40 | text=text or "", 41 | locale=locale or "", 42 | attachments=attachments_aux, 43 | entities=[], 44 | ) 45 | -------------------------------------------------------------------------------- /libraries/botbuilder-core/botbuilder/core/private_conversation_state.py: -------------------------------------------------------------------------------- 1 | from .bot_state import BotState 2 | from .turn_context import TurnContext 3 | from .storage import Storage 4 | 5 | 6 | class PrivateConversationState(BotState): 7 | def __init__(self, storage: Storage, namespace: str = ""): 8 | async def aux_func(context: TurnContext) -> str: 9 | nonlocal self 10 | return await self.get_storage_key(context) 11 | 12 | self.namespace = namespace 13 | super().__init__(storage, aux_func) 14 | 15 | def get_storage_key(self, turn_context: TurnContext) -> str: 16 | activity = turn_context.activity 17 | channel_id = activity.channel_id if activity is not None else None 18 | 19 | if not channel_id: 20 | raise Exception("missing activity.channel_id") 21 | 22 | if activity and activity.conversation and activity.conversation.id is not None: 23 | conversation_id = activity.conversation.id 24 | else: 25 | raise Exception("missing activity.conversation.id") 26 | 27 | if ( 28 | activity 29 | and activity.from_property 30 | and activity.from_property.id is not None 31 | ): 32 | user_id = activity.from_property.id 33 | else: 34 | raise Exception("missing activity.from_property.id") 35 | 36 | return f"{channel_id}/conversations/{ conversation_id }/users/{ user_id }/{ self.namespace }" 37 | -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/test_endorsements_validator.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from botframework.connector.auth import EndorsementsValidator 4 | 5 | 6 | class TestEndorsmentsValidator: 7 | def test_none_channel_id_parameter_should_pass(self): 8 | is_endorsed = EndorsementsValidator.validate(None, []) 9 | assert is_endorsed 10 | 11 | def test_none_endorsements_parameter_should_throw(self): 12 | with pytest.raises(ValueError) as excinfo: 13 | EndorsementsValidator.validate("foo", None) 14 | assert "endorsements" in excinfo 15 | 16 | def test_unendorsed_channel_id_should_fail(self): 17 | is_endorsed = EndorsementsValidator.validate("channelOne", []) 18 | assert not is_endorsed 19 | 20 | def test_mismatched_endorsements_channel_id_should_fail(self): 21 | is_endorsed = EndorsementsValidator.validate("right", ["wrong"]) 22 | assert not is_endorsed 23 | 24 | def test_endorsed_channel_id_should_pass(self): 25 | is_endorsed = EndorsementsValidator.validate("right", ["right"]) 26 | assert is_endorsed 27 | 28 | def test_endorsed_channel_id_should_pass_with_two_endorsements(self): 29 | is_endorsed = EndorsementsValidator.validate("right", ["right", "wrong"]) 30 | assert is_endorsed 31 | 32 | def test_unaffinitized_activity_should_pass(self): 33 | is_endorsed = EndorsementsValidator.validate("", ["right", "wrong"]) 34 | assert is_endorsed 35 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/luis/override_fill_recognizer.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | from typing import Dict 5 | 6 | from botbuilder.ai.luis import LuisRecognizer, LuisTelemetryConstants 7 | from botbuilder.core import RecognizerResult, TurnContext 8 | 9 | 10 | class OverrideFillRecognizer(LuisRecognizer): 11 | def __init__(self, *args, **kwargs): 12 | super(OverrideFillRecognizer, self).__init__(*args, **kwargs) 13 | 14 | def on_recognizer_result( 15 | self, 16 | recognizer_result: RecognizerResult, 17 | turn_context: TurnContext, 18 | telemetry_properties: Dict[str, str] = None, 19 | telemetry_metrics: Dict[str, float] = None, 20 | ): 21 | properties = super(OverrideFillRecognizer, self).fill_luis_event_properties( 22 | recognizer_result, turn_context, telemetry_properties 23 | ) 24 | 25 | if "MyImportantProperty" not in properties: 26 | properties["MyImportantProperty"] = "myImportantValue" 27 | 28 | # Log event 29 | self.telemetry_client.track_event( 30 | LuisTelemetryConstants.luis_result, properties, telemetry_metrics 31 | ) 32 | 33 | # Create second event. 34 | second_event_properties: Dict[str, str] = { 35 | "MyImportantProperty2": "myImportantValue2" 36 | } 37 | self.telemetry_client.track_event("MySecondEvent", second_event_properties) 38 | -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/recordings/test_conversations_send_to_conversation_with_invalid_conversation_id_fails.yaml: -------------------------------------------------------------------------------- 1 | interactions: 2 | - request: 3 | body: '{"recipient": {"id": "U19KH8EHJ:T03CWQ0QB"}, "channelId": "slack", "text": 4 | "Error!", "from": {"id": "B21UTEF8S:T03CWQ0QB"}, "type": "message"}' 5 | headers: 6 | Accept: [application/json] 7 | Accept-Encoding: ['gzip, deflate'] 8 | Connection: [keep-alive] 9 | Content-Length: ['142'] 10 | Content-Type: [application/json; charset=utf-8] 11 | User-Agent: [python/3.5.3 (Linux-4.11.0-041100-generic-x86_64-with-Ubuntu-17.04-zesty) 12 | requests/2.18.1 msrest/0.4.23 azure-botframework-connector/v3.0] 13 | method: POST 14 | uri: https://slack.botframework.com/v3/conversations/123/activities 15 | response: 16 | body: {string: "{\r\n \"error\": {\r\n \"code\": \"ServiceError\",\r\n \ 17 | \ \"message\": \"Invalid ConversationId: 123\"\r\n }\r\n}"} 18 | headers: 19 | cache-control: [no-cache] 20 | content-length: ['98'] 21 | content-type: [application/json; charset=utf-8] 22 | date: ['Tue, 26 Dec 2017 13:51:33 GMT'] 23 | expires: ['-1'] 24 | pragma: [no-cache] 25 | request-context: ['appId=cid-v1:6814484e-c0d5-40ea-9dba-74ff29ca4f62'] 26 | server: [Microsoft-IIS/10.0] 27 | strict-transport-security: [max-age=31536000] 28 | x-powered-by: [ASP.NET] 29 | status: {code: 400, message: Bad Request} 30 | version: 1 31 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/luis/test_data/MultipleIntents_PrebuiltEntitiesWithMultiValues.json: -------------------------------------------------------------------------------- 1 | { 2 | "query": "Please deliver February 2nd 2001 in room 201", 3 | "topScoringIntent": { 4 | "intent": "Delivery", 5 | "score": 0.8785189 6 | }, 7 | "intents": [ 8 | { 9 | "intent": "Delivery", 10 | "score": 0.8785189 11 | }, 12 | { 13 | "intent": "SpecifyName", 14 | "score": 0.0085189 15 | } 16 | ], 17 | "entities": [ 18 | { 19 | "entity": 2001, 20 | "type": "number", 21 | "startIndex": 28, 22 | "endIndex": 31 23 | }, 24 | { 25 | "entity": 201, 26 | "type": "number", 27 | "startIndex": 41, 28 | "endIndex": 43 29 | }, 30 | { 31 | "entity": 2, 32 | "type": "ordinal", 33 | "startIndex": 24, 34 | "endIndex": 26 35 | }, 36 | { 37 | "entity": "february 2nd 2001", 38 | "type": "builtin.datetimeV2.date", 39 | "startIndex": 15, 40 | "endIndex": 31, 41 | "resolution": { 42 | "values": [ 43 | { 44 | "timex": "2001-02-02", 45 | "type": "date", 46 | "value": "2001-02-02" 47 | } 48 | ] 49 | } 50 | } 51 | ] 52 | } -------------------------------------------------------------------------------- /libraries/botbuilder-dialogs/botbuilder/dialogs/prompts/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # -------------------------------------------------------------------------- 3 | # Copyright (c) Microsoft Corporation. All rights reserved. 4 | # Licensed under the MIT License. See License.txt in the project root for 5 | # license information. 6 | # -------------------------------------------------------------------------- 7 | 8 | from .activity_prompt import ActivityPrompt 9 | from .attachment_prompt import AttachmentPrompt 10 | from .choice_prompt import ChoicePrompt 11 | from .confirm_prompt import ConfirmPrompt 12 | from .datetime_prompt import DateTimePrompt 13 | from .datetime_resolution import DateTimeResolution 14 | from .number_prompt import NumberPrompt 15 | from .oauth_prompt import OAuthPrompt 16 | from .oauth_prompt_settings import OAuthPromptSettings 17 | from .prompt_options import PromptOptions 18 | from .prompt_recognizer_result import PromptRecognizerResult 19 | from .prompt_validator_context import PromptValidatorContext 20 | from .prompt import Prompt 21 | from .text_prompt import TextPrompt 22 | 23 | __all__ = [ 24 | "ActivityPrompt", 25 | "AttachmentPrompt", 26 | "ChoicePrompt", 27 | "ConfirmPrompt", 28 | "DateTimePrompt", 29 | "DateTimeResolution", 30 | "NumberPrompt", 31 | "OAuthPrompt", 32 | "OAuthPromptSettings", 33 | "PromptOptions", 34 | "PromptRecognizerResult", 35 | "PromptValidatorContext", 36 | "Prompt", 37 | "PromptOptions", 38 | "TextPrompt", 39 | ] 40 | -------------------------------------------------------------------------------- /libraries/botbuilder-ai/tests/luis/test_data/MultipleIntents_CompositeEntityModel.json: -------------------------------------------------------------------------------- 1 | { 2 | "query": "Please deliver it to 98033 WA", 3 | "topScoringIntent": { 4 | "intent": "Delivery", 5 | "score": 0.8785189 6 | }, 7 | "intents": [ 8 | { 9 | "intent": "Delivery", 10 | "score": 0.8785189 11 | } 12 | ], 13 | "entities": [ 14 | { 15 | "entity": "98033 wa", 16 | "type": "Address", 17 | "startIndex": 21, 18 | "endIndex": 28, 19 | "score": 0.864295959 20 | }, 21 | { 22 | "entity": "98033", 23 | "type": "builtin.number", 24 | "startIndex": 21, 25 | "endIndex": 25, 26 | "resolution": { 27 | "value": "98033" 28 | } 29 | }, 30 | { 31 | "entity": "wa", 32 | "type": "State", 33 | "startIndex": 27, 34 | "endIndex": 28, 35 | "score": 0.8981885 36 | } 37 | ], 38 | "compositeEntities": [ 39 | { 40 | "parentType": "Address", 41 | "value": "98033 wa", 42 | "children": [ 43 | { 44 | "type": "builtin.number", 45 | "value": "98033" 46 | }, 47 | { 48 | "type": "State", 49 | "value": "wa" 50 | } 51 | ] 52 | } 53 | ] 54 | } -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/recordings/test_conversations_create_conversation.yaml: -------------------------------------------------------------------------------- 1 | interactions: 2 | - request: 3 | body: '{"activity": {"recipient": {"id": "U19KH8EHJ:T03CWQ0QB"}, "channelId": 4 | "slack", "text": "Hi there!", "type": "message"}, "bot": {"id": "B21UTEF8S:T03CWQ0QB"}, 5 | "members": [{"id": "U19KH8EHJ:T03CWQ0QB"}]}' 6 | headers: 7 | Accept: [application/json] 8 | Accept-Encoding: ['gzip, deflate'] 9 | Connection: [keep-alive] 10 | Content-Length: ['202'] 11 | Content-Type: [application/json; charset=utf-8] 12 | User-Agent: [python/3.5.3 (Linux-4.11.0-041100-generic-x86_64-with-Ubuntu-17.04-zesty) 13 | requests/2.18.1 msrest/0.4.23 azure-botframework-connector/v3.0] 14 | method: POST 15 | uri: https://slack.botframework.com/v3/conversations 16 | response: 17 | body: {string: "{\r\n \"activityId\": \"1514296290.000025\",\r\n \"id\": \"\ 18 | B21UTEF8S:T03CWQ0QB:D2369CT7C\"\r\n}"} 19 | headers: 20 | cache-control: [no-cache] 21 | content-length: ['83'] 22 | content-type: [application/json; charset=utf-8] 23 | date: ['Tue, 26 Dec 2017 13:51:29 GMT'] 24 | expires: ['-1'] 25 | pragma: [no-cache] 26 | request-context: ['appId=cid-v1:6814484e-c0d5-40ea-9dba-74ff29ca4f62'] 27 | server: [Microsoft-IIS/10.0] 28 | strict-transport-security: [max-age=31536000] 29 | vary: [Accept-Encoding] 30 | x-powered-by: [ASP.NET] 31 | status: {code: 200, message: OK} 32 | version: 1 33 | -------------------------------------------------------------------------------- /libraries/botframework-connector/botframework/connector/auth/government_constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | from abc import ABC 4 | 5 | 6 | class GovernmentConstants(ABC): 7 | 8 | """ 9 | Government Channel Service property value 10 | """ 11 | 12 | CHANNEL_SERVICE = "https://botframework.azure.us" 13 | 14 | """ 15 | TO CHANNEL FROM BOT: Login URL 16 | """ 17 | TO_CHANNEL_FROM_BOT_LOGIN_URL = ( 18 | "https://login.microsoftonline.us/" 19 | "cab8a31a-1906-4287-a0d8-4eef66b95f6e/" 20 | "oauth2/v2.0/token" 21 | ) 22 | 23 | """ 24 | TO CHANNEL FROM BOT: OAuth scope to request 25 | """ 26 | TO_CHANNEL_FROM_BOT_OAUTH_SCOPE = "https://api.botframework.us/.default" 27 | 28 | """ 29 | TO BOT FROM CHANNEL: Token issuer 30 | """ 31 | TO_BOT_FROM_CHANNEL_TOKEN_ISSUER = "https://api.botframework.us" 32 | 33 | """ 34 | TO BOT FROM CHANNEL: OpenID metadata document for tokens coming from MSA 35 | """ 36 | TO_BOT_FROM_CHANNEL_OPEN_ID_METADATA_URL = ( 37 | "https://login.botframework.azure.us/v1/.well-known/openidconfiguration" 38 | ) 39 | 40 | """ 41 | TO BOT FROM GOV EMULATOR: OpenID metadata document for tokens coming from MSA 42 | """ 43 | TO_BOT_FROM_EMULATOR_OPEN_ID_METADATA_URL = ( 44 | "https://login.microsoftonline.us/" 45 | "cab8a31a-1906-4287-a0d8-4eef66b95f6e/v2.0/" 46 | ".well-known/openid-configuration" 47 | ) 48 | -------------------------------------------------------------------------------- /samples/13.core-bot/cards/welcomeCard.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", 3 | "type": "AdaptiveCard", 4 | "version": "1.0", 5 | "body": [ 6 | { 7 | "type": "Image", 8 | "url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQtB3AwMUeNoq4gUBGe6Ocj8kyh3bXa9ZbV7u1fVKQoyKFHdkqU", 9 | "size": "stretch" 10 | }, 11 | { 12 | "type": "TextBlock", 13 | "spacing": "medium", 14 | "size": "default", 15 | "weight": "bolder", 16 | "text": "Welcome to Bot Framework!", 17 | "wrap": true, 18 | "maxLines": 0 19 | }, 20 | { 21 | "type": "TextBlock", 22 | "size": "default", 23 | "isSubtle": "true", 24 | "text": "Now that you have successfully run your bot, follow the links in this Adaptive Card to expand your knowledge of Bot Framework.", 25 | "wrap": true, 26 | "maxLines": 0 27 | } 28 | ], 29 | "actions": [ 30 | { 31 | "type": "Action.OpenUrl", 32 | "title": "Get an overview", 33 | "url": "https://docs.microsoft.com/azure/bot-service/?view=azure-bot-service-4.0" 34 | }, 35 | { 36 | "type": "Action.OpenUrl", 37 | "title": "Ask a question", 38 | "url": "https://stackoverflow.com/questions/tagged/botframework" 39 | }, 40 | { 41 | "type": "Action.OpenUrl", 42 | "title": "Learn how to deploy", 43 | "url": "https://docs.microsoft.com/azure/bot-service/bot-builder-howto-deploy-azure?view=azure-bot-service-4.0" 44 | } 45 | ] 46 | } -------------------------------------------------------------------------------- /samples/experimental/101.corebot-bert-bidaf/model_runtime_svc/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Microsoft Corporation. All rights reserved. 2 | # Licensed under the MIT License. 3 | 4 | import os 5 | from setuptools import setup 6 | 7 | REQUIRES = [ 8 | "scikit-learn>=0.21.2", 9 | "scipy>=1.3.0", 10 | "tornado>=6.0.2", 11 | "model_corebot101>=0.0.1", 12 | ] 13 | 14 | root = os.path.abspath(os.path.dirname(__file__)) 15 | 16 | with open(os.path.join(root, "model_runtime_svc_corebot101", "about.py")) as f: 17 | package_info = {} 18 | info = f.read() 19 | exec(info, package_info) 20 | 21 | setup( 22 | name=package_info["__title__"], 23 | version=package_info["__version__"], 24 | url=package_info["__uri__"], 25 | author=package_info["__author__"], 26 | description=package_info["__description__"], 27 | keywords="botframework azure botbuilder", 28 | long_description=package_info["__summary__"], 29 | license=package_info["__license__"], 30 | packages=["model_runtime_svc_corebot101", "model_runtime_svc_corebot101.handlers"], 31 | install_requires=REQUIRES, 32 | dependency_links=["https://github.com/pytorch/pytorch"], 33 | include_package_data=True, 34 | classifiers=[ 35 | "Programming Language :: Python :: 3.6", 36 | "Intended Audience :: Developers", 37 | "License :: OSI Approved :: MIT License", 38 | "Operating System :: OS Independent", 39 | "Development Status :: 3 - Alpha", 40 | "Topic :: Scientific/Engineering :: Artificial Intelligence", 41 | ], 42 | ) 43 | -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/recordings/test_conversations_reply_to_activity_with_invalid_conversation_id_fails.yaml: -------------------------------------------------------------------------------- 1 | interactions: 2 | - request: 3 | body: '{"type": "message", "channelId": "slack", "from": {"id": "B21UTEF8S:T03CWQ0QB"}, 4 | "recipient": {"id": "U19KH8EHJ:T03CWQ0QB"}, "textFormat": "markdown", "attachmentLayout": 5 | "list", "text": "Child activity."}' 6 | headers: 7 | Accept: [application/json] 8 | Accept-Encoding: ['gzip, deflate'] 9 | Connection: [keep-alive] 10 | Content-Length: ['205'] 11 | Content-Type: [application/json; charset=utf-8] 12 | User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.1 msrest/0.4.23 13 | azure-botframework-connector/3.0] 14 | method: POST 15 | uri: https://slack.botframework.com/v3/conversations/INVALID_ID/activities/INVALID_ID 16 | response: 17 | body: {string: "{\r\n \"error\": {\r\n \"code\": \"ServiceError\",\r\n \ 18 | \ \"message\": \"Invalid ConversationId: INVALID_ID\"\r\n }\r\n}"} 19 | headers: 20 | cache-control: [no-cache] 21 | content-length: ['105'] 22 | content-type: [application/json; charset=utf-8] 23 | date: ['Fri, 29 Dec 2017 18:02:59 GMT'] 24 | expires: ['-1'] 25 | pragma: [no-cache] 26 | request-context: ['appId=cid-v1:6814484e-c0d5-40ea-9dba-74ff29ca4f62'] 27 | server: [Microsoft-IIS/10.0] 28 | strict-transport-security: [max-age=31536000] 29 | x-powered-by: [ASP.NET] 30 | status: {code: 400, message: Bad Request} 31 | version: 1 32 | -------------------------------------------------------------------------------- /samples/python_django/13.core-bot/bots/resources/welcomeCard.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", 3 | "type": "AdaptiveCard", 4 | "version": "1.0", 5 | "body": [ 6 | { 7 | "type": "Image", 8 | "url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQtB3AwMUeNoq4gUBGe6Ocj8kyh3bXa9ZbV7u1fVKQoyKFHdkqU", 9 | "size": "stretch" 10 | }, 11 | { 12 | "type": "TextBlock", 13 | "spacing": "medium", 14 | "size": "default", 15 | "weight": "bolder", 16 | "text": "Welcome to Bot Framework!", 17 | "wrap": true, 18 | "maxLines": 0 19 | }, 20 | { 21 | "type": "TextBlock", 22 | "size": "default", 23 | "isSubtle": "true", 24 | "text": "Now that you have successfully run your bot, follow the links in this Adaptive Card to expand your knowledge of Bot Framework.", 25 | "wrap": true, 26 | "maxLines": 0 27 | } 28 | ], 29 | "actions": [ 30 | { 31 | "type": "Action.OpenUrl", 32 | "title": "Get an overview", 33 | "url": "https://docs.microsoft.com/en-us/azure/bot-service/?view=azure-bot-service-4.0" 34 | }, 35 | { 36 | "type": "Action.OpenUrl", 37 | "title": "Ask a question", 38 | "url": "https://stackoverflow.com/questions/tagged/botframework" 39 | }, 40 | { 41 | "type": "Action.OpenUrl", 42 | "title": "Learn how to deploy", 43 | "url": "https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-howto-deploy-azure?view=azure-bot-service-4.0" 44 | } 45 | ] 46 | } -------------------------------------------------------------------------------- /libraries/botframework-connector/tests/recordings/test_conversations_create_conversation_with_invalid_bot_id_fails.yaml: -------------------------------------------------------------------------------- 1 | interactions: 2 | - request: 3 | body: '{"bot": {"id": "INVALID"}, "members": [{"id": "U19KH8EHJ:T03CWQ0QB"}], 4 | "activity": {"type": "message", "channelId": "slack", "from": {"id": "INVALID"}, 5 | "recipient": {"id": "U19KH8EHJ:T03CWQ0QB"}, "textFormat": "markdown", "attachmentLayout": 6 | "list", "text": "Hi there!"}}' 7 | headers: 8 | Accept: [application/json] 9 | Accept-Encoding: ['gzip, deflate'] 10 | Connection: [keep-alive] 11 | Content-Length: ['271'] 12 | Content-Type: [application/json; charset=utf-8] 13 | User-Agent: [python/3.6.2 (Windows-10-10.0.16299-SP0) requests/2.18.1 msrest/0.4.23 14 | azure-botframework-connector/3.0] 15 | method: POST 16 | uri: https://slack.botframework.com/v3/conversations 17 | response: 18 | body: {string: "{\r\n \"error\": {\r\n \"code\": \"ServiceError\",\r\n \ 19 | \ \"message\": \"Invalid userId: INVALID\"\r\n }\r\n}"} 20 | headers: 21 | cache-control: [no-cache] 22 | content-length: ['94'] 23 | content-type: [application/json; charset=utf-8] 24 | date: ['Fri, 29 Dec 2017 15:25:45 GMT'] 25 | expires: ['-1'] 26 | pragma: [no-cache] 27 | request-context: ['appId=cid-v1:6814484e-c0d5-40ea-9dba-74ff29ca4f62'] 28 | server: [Microsoft-IIS/10.0] 29 | strict-transport-security: [max-age=31536000] 30 | x-powered-by: [ASP.NET] 31 | status: {code: 400, message: Bad Request} 32 | version: 1 33 | --------------------------------------------------------------------------------