Skip to main content

Simplified serverless Slack bot interactions

Project description

Utility library for serverless Slack apps

PyPI

This is a (currently very simple) library that eases development of serverless Slack app and bots.

Currently, it targets Google Cloud Platform (but is easily generalised), and provides a decorator and some utility functions that make Slack signature verification automatic and help with building responses in a very lightweight fashion.

I will grow it with things I end up needing in my work, but if you have different needs and want to extend the library to support them, then PRs would be gratefully received!

MVP Example

This will accept any slash command you've configured for your bot, and just greet the user who calls it, tagging them in the reply.

from slack_serverless import slack_slash_command_gcp
from slack_messaging import slack_in_channel_text_response, slack_tags

@slack_slash_command_gcp(slack_signing_key=YOUR_SIGNING_KEY)
def command_handler(payload):
    return slack_in_channel_text_response(f"Hi there <@{slack_tags([payload['user_id']])}>")

Other Cloud Providers

Things will be a bit more manual here (but I'll happily add comfort wrappers if there's enough call and a PR that contributes them 😉).

The easiest thing to do is use the slack_slash_command decorator, which is similar to the gcp one above but needs you pass in a couple of Callables the code will use to get access to the data in a provider-specific way.

Take a look at the code in slack_serverless.py for examples to get you started.

Developing

Don't forget to set up pre-commit if you're developing things, especially if you plan to push a PR.

Legal Mumbo-Jumbo

Copyright (c)2023 Ross Bamford (and contributors)

License: MIT (see LICENSE.md for details).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slack-serverless-2023.1003a0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

slack_serverless-2023.1003a0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file slack-serverless-2023.1003a0.tar.gz.

File metadata

  • Download URL: slack-serverless-2023.1003a0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for slack-serverless-2023.1003a0.tar.gz
Algorithm Hash digest
SHA256 ab38f338d3ab20bc26240a243a6218cb6a73f254f19fe8a57460c69d52704090
MD5 b2a50b17eaf5aac6b266d22a89b6643a
BLAKE2b-256 004e168f5104de84e99a28fe8121399b28b6c69078ae4019c97d1f5676cf9645

See more details on using hashes here.

File details

Details for the file slack_serverless-2023.1003a0-py3-none-any.whl.

File metadata

File hashes

Hashes for slack_serverless-2023.1003a0-py3-none-any.whl
Algorithm Hash digest
SHA256 43dfcfe3e32ef90f93d8552bd42bc992215a5eedafe757856d2b0e032243031d
MD5 1b3dfc88ec0c00c10f41ef8e89a1f842
BLAKE2b-256 7873b44ced9f8963ada7f63f11d8b61afc8caa22751dc89fb56984db97adea98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page