async def _find_trigger(self,<EOL>request: Request,<EOL>origin: Optional[Text]=None,<EOL>internal: bool=False)-> Tuple[<EOL>Optional[BaseTrigger],<EOL>Optional[Type[BaseState]],<EOL>Optional[bool],<EOL>]:
reg = request.register<EOL>if not origin:<EOL><INDENT>origin = reg.get(Register.STATE)<EOL>logger.debug('<STR_LIT>', origin)<EOL><DEDENT>results = await asyncio.gather(*(<EOL>x.rank(request, origin)<EOL>for x<EOL>in self.transitions<EOL>if x.internal == internal<EOL>))<EOL>if len(results):<EOL><INDENT>score, trigger, state, dnr = max(results, key=lambda x: x[<NUM_LIT:0>])<EOL>if score >= settings.MINIMAL_TRIGGER_SCORE:<EOL><INDENT>return trigger, state, dnr<EOL><DEDENT><DEDENT>return None, None, None<EOL>
Find the best trigger for this request, or go away.