Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 'diaglog' webhook function in recent mmpy version #545

Open
Class-D-personnel opened this issue Sep 2, 2024 · 1 comment
Open

The 'diaglog' webhook function in recent mmpy version #545

Class-D-personnel opened this issue Sep 2, 2024 · 1 comment

Comments

@Class-D-personnel
Copy link

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))
@mexworthy
Copy link

I have the same question - if you find out the answer please update us here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants