The 'diaglog' webhook function in recent mmpy version
Operating Environment (please complete the following information):
- mmpy_bot Version: 2.1.4
- mattermostautodriver Version: 1.2.2
- Python Version: 3.8
- OS: Windows 10
Additional context Hello there. Recently I've tried some code with mmpy_bot so that making chat bots, most of things are going good, except webhook dialog. I found old version of 'webhook example.py' like below and there is code about 'dialog' case, where user can input some texts like survey. But when it comes to 2.x.x, that example is not anywhere now and there is no clue about the dialog webhook. I wanna set some survey form in chat bot, not only interactive buttons, so is there any available example of dialog(or something like text input function) in python using mmpy-bot?
(With below code now, Error occured.) AttributeError: 'IntegrationActions' object has no attribute 'open_dialog'
@listen_webhook("dialog")
def dialog_listener(self, event: WebHookEvent):
if isinstance(event, ActionEvent):
self.driver.respond_to_web(
event,
{
"update": {"message": event.context["text"], "props": {}},
"ephemeral_text": "dialog",
},
)
options = {
"trigger_id" : event.trigger_id,
"url": f"{self.webhook_host_url}:{self.webhook_host_port}/hooks/dialog_submit",
"dialog" : {
"callback_id": "email-edit",
"title": 'dialog title',
"elements": [
{
"display_name": "Email",
"name": "email",
"type": "text",
"subtype": "email",
"placeholder": "[email protected]"
}
],
"notify_on_cancel": False
}
}
self.driver.integration_actions.open_dialog(options)
else:
pass
@listen_webhook("dialog_submit")
def dialog_submit_listener(self, event):
print (event.body)
channel_id = event.body["channel_id"]
submit_data = event.body["submission"]
self.driver.create_post(channel_id=channel_id, message=str(submit_data))
I have the same question - if you find out the answer please update us here!
This is way too late, but in case any other users are encountering this, it should be open_interactive_dialog instead of open_dialog. E.g.: self.driver.integration_actions.open_interactive_dialog()
See docs of the mattermostautodriver: https://embl-bio-it.github.io/python-mattermost-autodriver/endpoints.html#mattermostautodriver.endpoints.integration_actions.IntegrationActions
Thanks @SerhatG for the correction and link to the driver documentation.
Unfortunately, as pointed out, the documented examples and the original API specification have deviated slightly. As capacity to maintain all fronts of the project is a bit limited, we would appreciate any help (read pull requests) with corrections such as this one to documentation or other parts.
Thanks @SerhatG for the correction and link to the driver documentation.
Unfortunately, as pointed out, the documented examples and the original API specification have deviated slightly. As capacity to maintain all fronts of the project is a bit limited, we would appreciate any help (read pull requests) with corrections such as this one to documentation or other parts.
Ah, I did a quick search before writing this and couldn't find the example anymore using this. I'll subscribe to this repository and hopefully that will help me contribute by keeping track of any issues/changes. I am also planning on implementing the new multi-step interactive dialogs, and if I get this to work, I'll see if I can put an example up.
Thanks @SerhatG . There's an older issue #140 on how to implement conversational interactions. This was asked back when version 1.x was in-use but 2.x didn't necessarily made it easier.
Dialogs are indeed an alternative and I confirm that they work. A long while ago I have succeeded in implementing a two-step workflow. Unfortunately I no longer have that code so I can't paste it here.
I didn't go further than two steps but it started to get painful to expand. If you have ideas/suggestions on how to improve this there's definitely space and we could include new tooling in mmpy_bot to help.
Thanks @SerhatG . There's an older issue #140 on how to implement conversational interactions. This was asked back when version 1.x was in-use but 2.x didn't necessarily made it easier.
Dialogs are indeed an alternative and I confirm that they work. A long while ago I have succeeded in implementing a two-step workflow. Unfortunately I no longer have that code so I can't paste it here.
I didn't go further than two steps but it started to get painful to expand. If you have ideas/suggestions on how to improve this there's definitely space and we could include new tooling in
mmpy_botto help.
Ah yes. I have a three-step workflow using Interactive Dialogs working by using a workaround (it only works on the Desktop app, the mobile app refuses to). But since the latest Mattermost (11.1) they support this functionality natively. So hopefully when I get this to work I can at least create a nice example on how to achieve this, but will think about the tooling issue as well. I wanted to do that for my current implementation but just didn't get there priority-wise.