def open_modal(trigger_id: str): try: view = View(type="modal", callback_id="modal-id", title=PlainTextObject(text="Awesome Modal"), submit=PlainTextObject(text="Submit"), close=PlainTextObject(text="Cancel"), blocks=[ InputBlock(block_id="b-id-1", label=PlainTextObject(text="Input label"), element=ConversationSelectElement( action_id="a", default_to_current_conversation=True, )), InputBlock(block_id="b-id-2", label=PlainTextObject(text="Input label"), element=ConversationMultiSelectElement( action_id="a", max_selected_items=2, default_to_current_conversation=True, )), ]) api_response = client.views_open(trigger_id=trigger_id, view=view) return make_response("", 200) except SlackApiError as e: code = e.response["error"] return make_response(f"Failed to open a modal due to {code}", 200)
def test_document(self): input = { "action_id": "text1234", "type": "conversations_select", "placeholder": { "type": "plain_text", "text": "Select an item" }, "initial_conversation": "C123", "response_url_enabled": True, "filter": { "include": ["public", "mpim"], "exclude_bot_users": True }, } self.assertDictEqual(input, ConversationSelectElement(**input).to_dict())