Decorators

watson_workspace_sdk.decorators.filter_workspace_annotations(whitelist=[], blacklist=[])

Drops and/or allows through specific annotations. Useful to cut out the Watson annotation calls that are not too informative.

blacklist = [toscana-words] # Drop these annotations.

whitelist = [“generic”] # These are standard chat messages from users

whitelist = [“actionSelected”, “generic” # Allows user chat messages and action events such as clicking a button, slash command or clicking on a focus annotation.

Parameters:
  • whitelist – List of annotations to allow
  • blacklist – List of annotations to drop
Returns:

Incoming request

Use: After a user creates a message, Workspace will annotate the message extracting Workspace Moment data. This is a message-annotation-edited event, and the annotation type will be a conversation-moment. My app has no use for this information so will be dropped.

watson_workspace_sdk.decorators.handle_verification(webhook_secret: str)

Checks if incoming request is a periodic Watson Workspace Verification message and replies to the challenge.

Parameters:webhook_secret – Webhook secret - Found in Watson Workspace application page.
Returns:Incoming request
watson_workspace_sdk.decorators.ignore_bots()

Ignore all messages from Watson Workspace bots/Apps

watson_workspace_sdk.decorators.timer()
watson_workspace_sdk.decorators.user_blacklist(blacklist)

Ignores messages from a blacklist of user ids

watson_workspace_sdk.decorators.user_whitelist(whitelist)

Ignore all messages unless a user is on a whitelist of user ids

watson_workspace_sdk.decorators.verify_workspace_origin(webhook_secret: str)

Checks incoming flask requests and ensures message came from Watson Workspace. If request does not originate from workspace it is logged and dropped.

Parameters:webhook_secret – Webhook secret - Found in Watson Workspace application page.
Returns:Incoming request