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

Add chat context to chatops #4609

Merged
merged 4 commits into from
Mar 29, 2019
Merged

Add chat context to chatops #4609

merged 4 commits into from
Mar 29, 2019

Conversation

blag
Copy link
Contributor

@blag blag commented Mar 23, 2019

This is part of the work to add a Microsoft Teams (via BotFramework) adapter.

Microsoft Teams needs a bit more context other than the requesting user and the channel name.

Instead of adding the minimum amount of context, this PR adds a context parameter to the post_ actions in the chatops pack and adds it to the notify on_complete dictionary. The context parameter maximizes the amount of information available to the notification mechanism, in the hopes that it can be reused by other adapters.

@Kami Kami added this to the 3.0.0 milestone Mar 25, 2019
@Kami Kami added the chatops label Mar 25, 2019
@Kami
Copy link
Member

Kami commented Mar 25, 2019

I like the idea of more generic context parameter.

Only thing I don't like about such "generic" dictionary parameters is usually lack of schema / structure. We had a "problem" with that in Mistral workflows where it wasn't always clear which attributes are available to the user in that context dictionary.

So at the very least we should document possible attributes in this dictionary where it's applicable.

@blag
Copy link
Contributor Author

blag commented Mar 29, 2019

@Kami

Only thing I don't like about such "generic" dictionary parameters is usually lack of schema / structure. We had a "problem" with that in Mistral workflows where it wasn't always clear which attributes are available to the user in that context dictionary.

It's not really possible to define much of a schema - the actual dictionary schema will be specific to each hubot adapter. But it should only be passed back to the chatops.post_message action and forwarded back to hubot. The hubot adapter, also being specific to each chat service, will know what to do with it.

@nzlosh
Copy link
Contributor

nzlosh commented May 2, 2019

I just saw this pull request. Will these contexts specific to hubot adapters be documented or would other project maintainers using the chatops pack need to reverse engineer hubot to maintain compatibility?

@blag
Copy link
Contributor Author

blag commented May 2, 2019

@nzlosh Right now, the only provider that uses the source_context is Microsoft Teams, and the context is simply sent right back to the hubot-botframework adapter - it isn't actually used by anything else (yet).

ChatOps is one place where we can use better documentation, including developer documentation. While we can document the entire context received from each supported chat provider, some providers may change their sent context over time. Slack, especially, changes their API a lot. So while we will try to document the context sent by each supported provider, it will be a "best effort" approach, and certainly may be out of date as time goes on/across version changes. This is, of course, an area where we would appreciate pull requests from the community.

@nzlosh
Copy link
Contributor

nzlosh commented May 2, 2019

Thanks @blag, I appreciate the explanation and understand external API stability guarantees are not easy to handle. My concern with the addition of the free form source_context field is StackStorm's API is no longer guaranteed from an external project maintainer point of view.

The match_and_execute API is very explicit with expected data structures and their intended use.

object
command string Command string to parse (eg: message from chat) required
user string User that requested the execution (or messaged in chat) required
source_channel string Channel the message is from (different than the notification channel) required
notification_channel string StackStorm notification channel to use to respond
notification_route string StackStorm notification route to use to respond

The new field source_context can only really be documented as an object without any additional structured information because that depends on hubot adapters and can change independently of the official st2 API.

I raise this point with maintaining coherency and compatibility in mind for projects that use the action-alias API and chatops pack. I know there aren't many projects impacted by this concern and I understand that there is no requirement for StackStorm to provide such a contract.

@blag
Copy link
Contributor Author

blag commented May 2, 2019

The problem with source_channel is that it doesn't apply to all chat providers. The MS Teams provider, for instance, sends a giant object with all sorts of redundant data, and expects to receive that same giant object when posting back to the provider. The concept of a "source channel" simply does not apply to users using MS Teams - it needs the whole object, and the object cannot be constructed because MS Teams is not built around a Slack-like (or really IRC-like) concept of channels.

The end result is that there are now two paths for providers to provide data - the user and source_channel strings, or one giant source_context blob. The giant object blob can encapsulate user and source_channel strings, so I think that is a better paradigm to use. Of course I do recognize that current users expect the current user and source_channel strings, so at some point in the future, if I have my way there will be a deprecation period where we transition to using a source_context object. But this is in no way set in stone.

At this point it is premature to bikeshed about what this will look like, as I have a lot more work to do before approaching this change again.

Kami added a commit that referenced this pull request May 7, 2019
Kami pushed a commit that referenced this pull request May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants