It took a while but I managed to create the integration with Make and wait for the Make response to enrich the conversation with the user.
This means you can send a request to Make, wait for Make to do something with it (e.g. check calendar availability, book an appointment, extract information from a CRM based on payload) and send the information back with the 200 response. The information is passed to the LLM that can use it to provide specific answers to the user…unlimited possibilities!
Code below.
Note you will need to edit / add the variables you need
import requests
def make_webhook(player_name: str):
"""
Send a request to Make.com when the chat ends and capture the response.
Args:
player_name (string): The player's name at the end of the chat.
"""
# Your Make.com webhook URL
url = "https://hook.eu2.make.com/XXXXXXXXXXXX"
# Payload to send with the request
payload = {
"player_name": player_name
}
# Log payload to verify it
print("Payload being sent:", payload)
# Sending the POST request to the webhook URL
try:
response = requests.post(url, json=payload, timeout=10)
# Log status code and response content
print(f"Status code: {response.status_code}")
print(f"Response content: {response.text}")
# Check if the request was successful
if response.status_code == 200:
# Capture response data
response_data = response.json()
print("Webhook sent successfully!")
print("Response from webhook:", response_data)
# Example: Extracting specific information from the response
message = response_data.get("message", "No message received")
additional_info = response_data.get("additional_info", {})
# Return AI-ready response
ai_response = {
"player_name": player_name,
"message": message,
"additional_info": additional_info
}
return ai_response
else:
print(f"Failed to send webhook. Status code: {response.status_code}, Response: {response.text}")
return None
except requests.exceptions.Timeout:
print("The request timed out")
return None
except requests.exceptions.RequestException as e:
# Handle any request exceptions
print(f"An error occurred: {e}")
return None
# Example usage:
player_name = "LeBron James" # Replace this with the actual player's name from the chat
ai_data = make_webhook(player_name) # Only calling make_webhook once and storing the result
# Checking if the ai_data is available and printing it
if ai_data:
print("AI can now process the following data:", ai_data)