If you want to post query results to a webhook (chat, glip, hipchat, slack)

1. Follow these AWS Lambda instructions

2. Use this code (but switch to python 3.6)

 

from __future__ import print_function

import os
import json
from botocore.vendored import requests

CONTENT = os.environ['content'] # Post content
TITLE = os.environ['title'] #Title
WEBHOOK = os.environ['webhook'] #Webhook to post to
ICON = os.environ['icon']

def lambda_handler(event, context):
data = {
'title': TITLE,
'body': requests.get(CONTENT).text.split('\n')[1].strip(),
'icon': ICON
}
print(data)
response = requests.post(
WEBHOOK,
json=data,
headers={'Content-Type': 'application/json'}
)
print(response)

if response.status_code != 200:
raise ValueError(
'Request to webook returned an error %s, the response is:\n%s'
% (response)
)
Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like1 Follow
  • 1 Likes
  • 9 mths agoLast active
  • 212Views
  • 1 Following