Closed
Description
Hi, I'm using Python bolt SDK and trying to read a message that got received on a specific slack channel. That message was delivered using the following webhook curl request:-
curl -X POST -H 'Content-type: application/json' -H 'Channel_Name: slave1_private' --data '{"text":"Hello, World!"}' <webhook url>\?channel_name\=slave1_private
I do not find any way of parsing either the custom header or query string from the following bolt code:-
from typing import Optional
import slack_sdk
import os
import logging
from pathlib import Path
from dotenv import load_dotenv
from slack_bolt import App
from slack_bolt.adapter.socket_mode import SocketModeHandler
logging.basicConfig(level=logging.DEBUG)
env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_path)
SLACK_VERIFICATION_TOKEN = os.environ['SLACK_VERIFICATION_TOKEN']
SLACK_SIGNING_SECRET = os.environ['SLACK_SIGNING_SECRET']
SLACK_BOT_TOKEN = os.environ['SLACK_BOT_TOKEN']
SLACK_APP_TOKEN = os.environ['SLACK_APP_TOKEN']
# Install the Slack app and get xoxb- token in advance
app = App(token=SLACK_BOT_TOKEN, signing_secret=SLACK_SIGNING_SECRET)
@app.event("message")
def handle_message(event, say, context):
# user = event["user"]
print("..app..", app.client.headers.get("Channel_Name"))
print('event:::::::::::::::::::', event)
print('context............', context)
text = event["text"]
channel = event["channel"]
# Access query parameters
# query_params = context.request.query
# print("Query Parameters:", query_params)
# print("event->>", event["headers"])
# Access channel name from the payload
# channel_name = event.get("channel_name")
# headers = event.get("headers", {}) # Access headers from the event data
# print("headers:::", headers)
# channel_name = headers.get("Channel_Name")
# print("Channel Name:", channel_name)
if __name__ == "__main__":
handler = SocketModeHandler(app, SLACK_APP_TOKEN)
handler.start()
Is there any support in the SDK to read the custom headers or query string?