Example #1
0
    def step(
        self,
        callback_id: Union[str, Pattern, WorkflowStep, WorkflowStepBuilder],
        edit: Optional[
            Union[Callable[..., Optional[BoltResponse]], Listener, Sequence[Callable]]
        ] = None,
        save: Optional[
            Union[Callable[..., Optional[BoltResponse]], Listener, Sequence[Callable]]
        ] = None,
        execute: Optional[
            Union[Callable[..., Optional[BoltResponse]], Listener, Sequence[Callable]]
        ] = None,
    ):
        """Registers a new Workflow Step listener
        Unlike others, this method doesn't behave as a decorator. If you want to register a workflow step
        by a decorator, use WorkflowStepBuilder's methods.
        """
        step = callback_id
        if isinstance(callback_id, (str, Pattern)):
            step = WorkflowStep(
                callback_id=callback_id,
                edit=edit,
                save=save,
                execute=execute,
            )
        elif isinstance(step, WorkflowStepBuilder):
            step = step.build()
        elif not isinstance(step, WorkflowStep):
            raise BoltError(f"Invalid step object ({type(step)})")

        self.use(WorkflowStepMiddleware(step, self.listener_runner))
Example #2
0
    def step(
        self,
        callback_id: Union[str, Pattern, WorkflowStep],
        edit: Optional[
            Union[Callable[..., Optional[BoltResponse]], Listener, Sequence[Callable]]
        ] = None,
        save: Optional[
            Union[Callable[..., Optional[BoltResponse]], Listener, Sequence[Callable]]
        ] = None,
        execute: Optional[
            Union[Callable[..., Optional[BoltResponse]], Listener, Sequence[Callable]]
        ] = None,
    ):
        """Registers a new Workflow Step listener"""
        step = callback_id
        if isinstance(callback_id, (str, Pattern)):
            step = WorkflowStep(
                callback_id=callback_id, edit=edit, save=save, execute=execute,
            )
        elif not isinstance(step, WorkflowStep):
            raise BoltError("Invalid step object")

        self.use(WorkflowStepMiddleware(step, self.listener_runner))
Example #3
0
                    "name": "taskAuthorEmail",
                    "type": "text",
                    "label": "Task Author Email",
                },
            ],
        },
        "event_ts": "1601541373.225894",
    },
    "type": "event_callback",
    "event_id": "Ev111",
    "event_time": 1601541373,
}

# https://api.slack.com/tutorials/workflow-builder-steps

copy_review_step = WorkflowStep.builder("copy_review")


@copy_review_step.edit
def edit(ack: Ack, step, configure: Configure):
    assert step is not None
    ack()
    configure(blocks=[
        {
            "type": "section",
            "block_id": "intro-section",
            "text": {
                "type":
                "plain_text",
                "text":
                "Create a task in one of the listed projects. The link to the task and other details will be available as variable data in later steps.",