01-02-2024, 03:07 PM
Happy New Year All!
I am in the process of extending my internal TACTIC system to handle CRM data. Part of this is using external services like GMass for email campaigns. Gmass has the ability to send webhooks on events in their system. Instead of taking the API route, I am thinking it will be interesting to use webhooks as this seems to be the way many apps communicate including things like Zapier.
So far, I have done some basic tests using the Python Webhooks Listener library (Webhook-Listener · PyPI). I think this is a good route as it uses CherryPy. I am using it's default use of port 8090 as I know tactic the standard web ports. So I mainly just needed to open port 8090 in the firewall.
Here is the webhooks_listener.py file I have on my server. I left the initial test print as it shows what is available in the event
Now all of that said, I have a few questions:
I am in the process of extending my internal TACTIC system to handle CRM data. Part of this is using external services like GMass for email campaigns. Gmass has the ability to send webhooks on events in their system. Instead of taking the API route, I am thinking it will be interesting to use webhooks as this seems to be the way many apps communicate including things like Zapier.
So far, I have done some basic tests using the Python Webhooks Listener library (Webhook-Listener · PyPI). I think this is a good route as it uses CherryPy. I am using it's default use of port 8090 as I know tactic the standard web ports. So I mainly just needed to open port 8090 in the firewall.
Here is the webhooks_listener.py file I have on my server. I left the initial test print as it shows what is available in the event
Code:
import time
import webhook_listener
def process_post_request(request, *args, **kwargs):
"""
print(
"Received request:\n"
+ "Method: {}\n".format(request.method)
+ "Headers: {}\n".format(request.headers)
+ "Args (url path): {}\n".format(args)
+ "Keyword Args (url parameters): {}\n".format(kwargs)
+ "Body: {}".format(
request.body.read(int(request.headers["Content-Length"]))
if int(request.headers.get("Content-Length", 0)) > 0
else ""
)
)
"""
# Process the request!
print(kwargs)
return
webhooks = webhook_listener.Listener(handlers={"POST": process_post_request})
webhooks.start()
while True:
print("Still alive...")
time.sleep(300)
Now all of that said, I have a few questions:
- Is there something already in place that makes this not necessary? I ask because I see some code for sending Webhooks from TACTIC
- If I was to use this code, what the best approach to adding it as a service that starts up when Tactic starts?