Action Call - Full integration with Make (Request + Response)

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)

11 Likes

Hi @ab2308,

Just a small correction on the code: you don’t have to call the function manually, as the bot will automatically call and fill in the player_name parameter for you.

Also, instead of using return, just print the data directly within the function. This will simplify things!

Example:

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/XXXXXXXX"
    
    # 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
            }
            print("AI can now process the following data:", ai_response)
        
        else:
            print(f"Failed to send webhook. Status code: {response.status_code}, Response: {response.text}")
    
    except requests.exceptions.Timeout:
        print("The request timed out")
    except requests.exceptions.RequestException as e:
        # Handle any request exceptions
        print(f"An error occurred: {e}")
4 Likes

Yes thank you for the suggestion

Brilliant , thank you for sharing this @ab2308

Thanks everyone. So where do you deploy this code?

My use case is. Please enter your name and email. Then use Make.com to send to CRM.

Thanks

Hi @lucidaisolutions

When you create the pickaxe you now have an act section to create the integration.

Unless you need to do other operations in Make, you can create an action with the CRM in Pickaxe (I’m assuming it has APIs if you are using Make to connect to it)

Yes, you can add this code in the “Act” section of the builder, as @andreab mentioned above. We have also just added a public Make integration which you should be able to see in the builder as well! It looks like this:
Screenshot 2024-09-29 at 11.28.29 AM

2 Likes

Thanks for sharing this and the updates. Awesome work! :grinning:

Thanks for the direction.

So does this mean I can have a Make scenario, and then get it to interact with a Pickaxe as part of the flow? Have I understood this correctly?

1 Like

Yes you can. But I am not finding that easy to do the integration. Sure, a simple one variable was ok, but beyond that, I cannot seem to figure it out.

I’m a little lost on the Make custom webhook action too.

How to make the integration retrieve order status data from a Google Sheet?

Hi @ned_rvth,

2 Likes

Also see Connecting Actions Tutorial - #18 by ned_rvth

1 Like