Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created April 7, 2025 17:15
Show Gist options
  • Select an option

  • Save KyMidd/89f33a05df453cca341c1011e90d6fd1 to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/89f33a05df453cca341c1011e90d6fd1 to your computer and use it in GitHub Desktop.
def lambda_handler(event, context):
# ....
# Get the event type
event_type = body.get('type', '')
# Check for edited messages
if (
event_type == 'event_callback' and
'edited' in body.get('event', {})
):
print('Detected edited message, discarding')
return {
'statusCode': 200,
'body': json.dumps({'message': 'Edited message discarded'})
}
# Only process events we care about
if event_type == 'event_callback':
# Asynchronously invoke the processor Lambda
lambda_client.invoke(
FunctionName=os.environ['PROCESSOR_FUNCTION_NAME'],
InvocationType='Event', # Async invocation
Payload=json.dumps(event)
)
# Always return 200 OK to Slack quickly
return {
'statusCode': 200,
'body': json.dumps({'message': 'Event received'})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment