-
Notifications
You must be signed in to change notification settings - Fork 110
Description
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))