Skip to content
Advertisement

Initial and send a message to a Microsoft Teams channel using Bot Framework SDK v4 for Python

I was trying to initial and send a proactive message to one Microsoft teams channel with the help of below example: https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/python/16.proactive-messages I added this code to the example in order to initiate a message:

connectorClient = await ADAPTER.create_connector_client(service_url=SERVICE_URL)
parameters = ConversationParameters(
        is_group=True,
        channel_data=CHANNEL_ID,
        activity=Activity(type=ActivityTypes.message,
        text='Hello World!'),
        bot=ChannelAccount(id=BOT_ID),
        tenant_id=TENANT_ID)
response = await connectorClient.conversations.create_conversation(parameters)
response.send()

But it didn’t work, and I tried many different ways and none of them worked too, always the error is:

Traceback (most recent call last):
File "/home/farid/works/16.proactive-messages/venv/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/home/farid/works/16.proactive-messages/venv/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/home/farid/works/16.proactive-messages/app.py", line 103, in notify
raise exception
File "/home/farid/works/16.proactive-messages/app.py", line 100, in notify
await _send_proactive_message()
File "/home/farid/works/16.proactive-messages/app.py", line 152, in _send_proactive_message
response = await connectorClient.conversations.create_conversation(parameters)
File "/home/farid/works/16.proactive-messages/venv/lib/python3.7/site-packages/botframework/connector/aio/operations_async/_conversations_operations_async.py", line 176, in create_conversation
raise models.ErrorResponseException(self._deserialize, response)
botbuilder.schema._models_py3.ErrorResponseException: (BadSyntax) Incorrect conversation creation parameters

I don’t know what is my problem here!

Advertisement

Answer

Ok, last night Microsoft added a new python sample which solved this issue: https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/python/58.teams-start-thread-in-channel

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement