Skip to main content

Microsoft Bot Framework Bot Builder SDK for Python.

Project description

Azure DevOps status for master branch Latest PyPI package version

Within the Bot Framework, the Bot Connector service enables your bot to exchange messages with users on channels that are configured in the Bot Framework Portal.

How to Install

pip install botframework-connector

How to Use

Authentication

Your bot communicates with the Bot Connector service using HTTP over a secured channel (SSL/TLS). When your bot sends a request to the Connector service, it must include information that the Connector service can use to verify its identity.

To authenticate the requests, you’ll need configure the Connector with the App ID and password that you obtained for your bot during registration and the Connector will handle the rest.

More information: https://docs.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-connector-authentication

Example

Client creation (with authentication), conversation initialization and activity send to user.

from microsoft.botbuilder.schema import *
from microsoft.botframework.connector import ConnectorClient
from microsoft.botframework.connector.auth import MicrosoftTokenAuthentication

APP_ID = '<your-app-id>'
APP_PASSWORD = '<your-app-password>'
SERVICE_URL = 'https://slack.botframework.com'
CHANNEL_ID = 'slack'
BOT_ID = '<bot-id>'
RECIPIENT_ID = '<user-id>'

credentials = MicrosoftTokenAuthentication(APP_ID, APP_PASSWORD)
connector = ConnectorClient(credentials, base_url=SERVICE_URL)

conversation = connector.conversations.create_conversation(ConversationParameters(
            bot=ChannelAccount(id=BOT_ID),
            members=[ChannelAccount(id=RECIPIENT_ID)]))

connector.conversations.send_to_conversation(conversation.id, Activity(
            type=ActivityTypes.message,
            channel_id=CHANNEL_ID,
            recipient=ChannelAccount(id=RECIPIENT_ID),
            from_property=ChannelAccount(id=BOT_ID),
            text='Hello World!'))

Rest API Documentation

For the Connector Service API Documentation, please see our API reference.

Documentation/Wiki

You can find more information on the botbuilder-python project by visiting our Wiki.

Requirements

Source Code

The latest developer version is available in a github repository: https://github.com/Microsoft/botbuilder-python/

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Reporting Security Issues

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) at secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.

License

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

botframework_connector-4.7.0-py2.py3-none-any.whl (65.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file botframework_connector-4.7.0-py2.py3-none-any.whl.

File metadata

  • Download URL: botframework_connector-4.7.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 65.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.8

File hashes

Hashes for botframework_connector-4.7.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cda906d817b2678e8c699fd2c46c77b63570c5d6b8d111d8b89ade026483543a
MD5 42a66c36a4304d2ba101fd159edda0f4
BLAKE2b-256 7e5e87f4a553d6cc9dc2d9576f6fa7d97c3ab98d370af204d42f44fb93333f39

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page