簡體   English   中英

MS團隊漫游器-創建新對話

[英]MS teams bot - create new conversation

我正在使用botbuilder-python構建MS Teams機器人。 在樣本之后,我將能夠響應消息。 我正在努力創建全新的消息,而沒有從Teams傳遞現有的活動。 我從測試中修改了一些代碼( https://github.com/Microsoft/botbuilder-python/blob/62b0512a4dd918fa0d3837207012b31213aaedcc/libraries/botframework-connector/tests/test_conversations.py )但我得到了:

botbuilder.schema.error_response_py3.ErrorResponseException:(BadSyntax)無法解析租戶ID

它是什么,我在哪里可以找到它(我可以從請求中釣出來,但這並不理想),我該如何傳遞它? 誰能指出我創建新對話的任何Python示例?

我想通了,以防萬一其他人試圖做同樣的事情而陷入困境:

to = ChannelAccount(id=to_user_id)

bot_channel = ChannelAccount(id=bot_id)
activity_reply = Activity(type=ActivityTypes.message, channel_id='msteams',from_property=bot_channel,recipient=to,text=message)

credentials=MicrosoftAppCredentials(app_id, app_password)
JwtTokenValidation.authenticate_request(activity_reply, "Authorization", credentials)
# That's where you pass the tenant id
reply_conversation_params=ConversationParameters(bot=bot_channel, members=[to], activity=activity_reply, channel_data={ 'tenant': { 'id': tenant_id } })
connector = ConnectorClient(credentials, base_url='https://smba.trafficmanager.net/uk/')

# Create conversation
conversation = connector.conversations.create_conversation(reply_conversation_params)
# And send it
connector.conversations.send_to_conversation(conversation.id, activity_reply)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM