This is a decorator intended to be used on states (and actually only
        work on state handlers).

        The `require` argument is a list of keys to be checked in the context.
        If at least one of them is missing, then instead of calling the handler
        another method will be called. By default the method is
        `missing_context` but it can be configured using the `fail` argument.

        The context will be injected into the handler as a keyword arg. By
        default, the arg is expected to be named `context` but you can change
        it to anything you'd like using `var_name`.

        See `create_context_store()` for a full example.

def inject(self,
               require: Optional[List[Text]] = None,
               fail: Text = 'missing_context',
               var_name: Text = 'context'):
        """
        This is a decorator intended to be used on states (and actually only
        work on state handlers).

        The `require` argument is a list of keys to be checked in the context.
        If at least one of them is missing, then instead of calling the handler
        another method will be called. By default the method is
        `missing_context` but it can be configured using the `fail` argument.

        The context will be injected into the handler as a keyword arg. By
        default, the arg is expected to be named `context` but you can change
        it to anything you'd like using `var_name`.

        See `create_context_store()` for a full example.
        """

        def decorator(func):
            async def health_check(cls) -> Iterator[HealthCheckFail]:
                if not callable(getattr(cls, fail, None)):
                    yield HealthCheckFail(
                        '00001',
                        f'State "{cls.__name__}" has no method "{fail}" to '
                        f'fall back to if required attributes are missing '
                        f'from the context.'
                    )

            if require:
                func.health_check = health_check

            @wraps(func)
            async def wrapper(state: Union[BaseState, BaseTrigger], **kwargs):
                conv_id = state.request.conversation.id
                key = f'context::{self.name}::{conv_id}'

                x = self.open(key)
                async with x as context:
                    for item in (require or []):
                        if item not in context:
                            return await getattr(state, fail)(state, **kwargs)

                    kwargs[var_name] = context
                    return await func(state, **kwargs)

            return wrapper
        return decorator