Skip to content

Fix 1086 add interactivity patterns in SocketModeClient docs#1139

Merged
seratch merged 4 commits intoslackapi:mainfrom
ruberVulpes:fix-1086
Nov 29, 2021
Merged

Fix 1086 add interactivity patterns in SocketModeClient docs#1139
seratch merged 4 commits intoslackapi:mainfrom
ruberVulpes:fix-1086

Conversation

@ruberVulpes
Copy link
Copy Markdown
Contributor

Summary

Fixes #1086

Adds examples for Shortcuts and Modal submissions to the Socket Mode documentation.

I've run the synchronous version of the code and tested. For some reason the async code was failing with

sys:1: RuntimeWarning: coroutine 'AsyncBaseSocketModeClient.process_messages' was never awaited

on

asyncio.run(main())

I'm not to familiar with Python's aysnc, I also get this error with the version on main as well. It could also be an issue with me writing this on Windows.

Let me know if you'd like any changes to the non code documentation, I made it a bit verbose so that a first time user should be able to follow the guide but I'm unsure if that's the target audience.

Category (place an x in each of the [ ])

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.signature (Request Signature Verifier)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.models (UI component builders)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.rtm_v2 (RTM client)
  • /docs-src (Documents, have you run ./scripts/docs.sh?) 👍
  • /docs-src-v2 (Documents, have you run ./scripts/docs-v2.sh?)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

Requirements (place an x in each [ ])

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes.

I've also run ./scripts/docs.sh and confirmed the webpage matched what I expected

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 28, 2021

Codecov Report

Merging #1139 (d1def17) into main (010605f) will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1139   +/-   ##
=======================================
  Coverage   86.61%   86.62%           
=======================================
  Files         110      110           
  Lines       10754    10754           
=======================================
+ Hits         9315     9316    +1     
+ Misses       1439     1438    -1     
Impacted Files Coverage Δ
slack_sdk/socket_mode/builtin/internals.py 72.44% <0.00%> (+0.44%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 010605f...d1def17. Read the comment docs.

* Go to **Settings** > **Socket Mode**, then turn on **Enable Socket Mode**
* Go to **Features** > **App Home**, look under **Show Tabs** > **Messages Tab** then turn on **Allow users to send Slash commands and messages from the messages tab**
* Go to **Features** > **Event Subscriptions**, then turn on **Enable Events**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this and the change on L:20 would make the generated page look like this
image

with the current file ./scripts/docs.sh generates the following for me
image

if it still looks good on your end with the proposed changes I'll commit them, but I wanted to bring it up since it looks like the formatting might be wonky to me

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruberVulpes Thanks for clarifying this! Your changes look reasonable here.

* Go to **Features** > **Event Subscriptions**, then turn on **Enable Events**

* On the same page expand **Subscribe to bot events** click **Add Bot User Event** and select **message.im**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

timestamp=req.payload["event"]["ts"],
)
if req.type == "interactive" \
and req.payload["type"] == "shortcut":
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type can be None

Suggested change
and req.payload["type"] == "shortcut":
and req.payload.get("type") == "shortcut":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, never mind. As long as req.type == "interactive" is checked beforehand, accessing req.payload["type"] should be safe

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oop, I just pushed the changes for .get
I'm fine with leaving it .get incase people decide to later copy/paste from it since it should be safe if other payload types might not have the same guarantee

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, either is fine!

@seratch seratch self-assigned this Nov 28, 2021
@seratch seratch added this to the 3.13.0 milestone Nov 28, 2021
@seratch seratch added the docs M-T: Documentation work only label Nov 28, 2021
* Go to **Settings** > **Socket Mode**, then turn on **Enable Socket Mode**
* Go to **Features** > **App Home**, look under **Show Tabs** > **Messages Tab** then turn on **Allow users to send Slash commands and messages from the messages tab**
* Go to **Features** > **Event Subscriptions**, then turn on **Enable Events**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ruberVulpes Thanks for clarifying this! Your changes look reasonable here.

@ruberVulpes
Copy link
Copy Markdown
Contributor Author

Also I was thinking that when App Manifests go GA it might be cool to use those for the app configs. It won't give the users the experience of clicking through the UI but it should be a more concise guide

@seratch
Copy link
Copy Markdown
Contributor

seratch commented Nov 29, 2021

@ruberVulpes Thanks for working on these improvements! As for the App Manifest updates, yes, we can consider updating the documents when it becomes GA.

@seratch seratch merged commit db962db into slackapi:main Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs M-T: Documentation work only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add interactivity patterns in SocketModeClient document

2 participants