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

spoken_to matcher #273

Open
go8ose opened this issue Oct 18, 2017 · 3 comments
Open

spoken_to matcher #273

go8ose opened this issue Oct 18, 2017 · 3 comments

Comments

@go8ose
Copy link
Contributor

go8ose commented Oct 18, 2017

I've been thinking about the context issue, #156. I think another element of context is whether or not the bot is directly addressed by the user. You might only want a skill to be invoked if a user messages the bot in a direct one-to-one channel, or specifically mentions the bots name in the message.

For example, you might want to distinguish between these two interactions:
john> @bot can you please Delete all the things?


john> and then, can you believe it, this guy said to his home assistant "Delete all the things" and that silly bot went ahead and did it!

An example matcher might be:

@match_spoken_to()
@match_regex("Delete all the things")
async def delete(opsdroid, config, message):
    opsdroid.context.update_session('question', 'delete-everything')
    await message.respond('Are you sure?')
…

This could be part of a new match_context(), but it feels fairly specific. I wonder if the there might be a family of matchers under the 'context' umbrella, instead of one matcher.

@jacobtomlinson
Copy link
Member

Yeah I've thought about this before, but this seems like a neat approach!

I know in other bot frameworks like Hubot there is a distinction between hear and respond where the first is for overhearing within general chat and the second is direct messages only.

Just thinking about how this could be implemented. The Message object could have a direct parameter which is boolean and is set by the connector. This way the connector can parse whether the message was said in a private message or whether the message was prefixed by the bot's username. This would be a breaking change to the Message and Connector classes.

@jacobtomlinson
Copy link
Member

jacobtomlinson commented Oct 19, 2017

Also not sure if I like @match_spoken_to, perhaps there is a better way to phrase it.

For example it's probably best to keep a distinction between the matchers and the constraints, so it could be @constraint_direct_message or @constraint_spoken_to.

@jacobtomlinson
Copy link
Member

To build on #933 we could add a parse step which infers whether a message was intended to be direct to the bot.

This could be by having the bots name at the beginning of the message, being in a DM room with the bot or maybe even by some more advanced NLU.

This parser would add a property to the event that it was direct which could then be filtered on with a constraint.

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

No branches or pull requests

3 participants