Ниже приведен пример адаптивной карточки, которая имеет тип = "task/fetch" для действия, которое при нажатии должно открыть модальное окно задачи.
Код: Выделить всё
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.4",
"body": [
{
"type": "TextBlock",
"text": "Available Options",
"weight": "Bolder",
"size": "Large"
},
{
"type": "Container",
"items": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "Image",
"url": "https://picsum.photos/200",
"size": "Small"
},
{
"type": "TextBlock",
"text": "Create Option",
"weight": "Bolder"
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.Submit",
"title": "Create new",
"data": {
"msteams": {
"type": "task/fetch"
},
"action": "createOption"
}
}
]
}
]
}
]
}
]
}
]
}
Код: Выделить всё
settings = BotFrameworkAdapterSettings(bot_id, bot_password)
adapter = BotFrameworkAdapter(settings)
async def turn_logic(turn_context: TurnContext):
typing_activity = Activity(type=ActivityTypes.typing)
await turn_context.send_activity(typing_activity)
if turn_context.activity.type == "invoke" and turn_context.activity.name == "task/fetch":
task_response = Activity(
type=ActivityTypes.invoke_response,
value=InvokeResponse(
status=200,
body={
"task": {
"type": "continue",
"value": {
"title": "Create Form",
"height": "large",
"width": "large",
"card": {
"contentType": "application/vnd.microsoft.card.adaptive",
"content": get_form_adaptive_card()
}
}
}
}
)
)
await turn_context.send_activity(task_response)
def initiate_task_loop(request, callback):
body = request.json
activity = Activity().deserialize(body)
auth_header = request.headers["Authorization"]
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
task = adapter.process_activity(activity, auth_header, callback)
loop.run_until_complete(task)
finally:
loop.close()
@app.route("/", methods=["POST"])
def messages():
try:
initiate_task_loop(request, turn_logic)
return jsonify({"status": "ok"}), 200
except Exception as e:
import traceback
print(str(e))
print("".join(traceback.format_tb(e.__traceback__)))
return jsonify({"error": str(e)}), 500
Код: Выделить всё
{
"errorCode": 1008,
"message": "Error when processing invoke response: Task or Task Type is missing in Task Module response",
"standardizedError": {
"errorCode": 1008,
"errorSubCode": 1,
"errorDescription": "Error when processing invoke response: Task or Task Type is missing in Task Module response"
}
}
[img]https://i. sstatic.net/UD5vQ74E.png[/img]
У меня нет файла манифеста.json в коде моего локального приложения, у меня все настроено на платформе разработки MSFT.
Подробнее здесь: https://stackoverflow.com/questions/793 ... voke-respo