I am trying to connect make.com webhook to my bot but the JSON I am receiving from the bot is not valid JSON.
Its just data with all the text in one data block even if I have for example a “title” and “content” that should be in the JSON.
How do I fix this so the bot actually sends the JSON in correct format to make.com webhook?
I need to be able to differentiate the data in JSON format and not just big “data” chunk with title and content reading in it but unable to differentiate them so I can place the different data in their own placements in make.com.
If this is not possible it really makes the whole make.com integration useless
Note that this is more than likely a user error on my side regarding the message I give to my bot or maybe something I’m not getting in make.com even though I tried different things.
Our “Basic” webhook actions only sends a JSON object with a data field. However, you can clone it to add additional input fields and modify the code to include these new inputs in the request payload.
This is what I was trying to do. But what I am getting is only the “data” field. Can you share your “input” to the bot to create this correct format since I think after that I can easily turn it to what I want.
Sorry, I am not following you on this. Can you explain how I can “clone” this to change the make.com integration so it would include a title and post fields separated so it can be handled correctly?
Hi friend, I also had the same problem and I managed to solve it. Here is the code, just copy and paste it and add fields according to what you need, delete the last name and age and add yours, once you add them in the code add them in the input field function of the action and after that it should work. code:
import os
import requests
def basic_make_webhook_multiple_fields(data: str, age: str, last_name: str):
“”"
Sends a basic request to a make.com webhook
Args:
data (string): username
age (string): age of the user
last_name (string): last name of the user
Envs:
MAKE_COM_WEBHOOK (string): Webhook link from Make.com
“”"
if response.status_code == 200:
return f"Successfully sent data. Result: {response.text}"
else:
return f"Failed to send data to Make. Status code: {response.status_code}, Response: {response.text}"
except Exception as e:
return f"An error occurred: {str(e)}"
If you still have problems, create a command that modifies the code and sends it to you ready to copy. Copy the Make code you are having problems with and tell it to add captions to send to the webhook and it will return the code ready to paste and use.: https://beta.pickaxeproject.com/axe?id=Code_generator_X4I7G
Tried creating this but kept getting errors from the pickaxe itself unfortunately. Hopefully the make.com integration is changed to better support something like this in the future since the custom function seems to just cause internal errors
Here is the code I have and for now I am still not understanding what I am doing wrong, considering this is almost word to word the code I got from you guys…
import os
import requests
def send_data_to_wordpress(title: str, content: str):
"""
Send generated blog post to make.com
Args:
title (string): Title of blog post
content (string): Content of blog post
Envs:
MAKE_COM_WEBHOOK (string): Make.com Webhook to connect more services
"""
# Insert your PYTHON code below. You can access environment variables using os.environ[].
# Currently, only the requests library is supported, but more libraries will be available soon.
# Use print statements or return values to display results to the user.
# If you save a png, pdf, csv, jpg, webp, gif, or html file in the root directory, it will be automatically displayed to the user.
# You do not have to call this function as the bot will automatically call and fill in the parameters.
try:
make_url = os.environ.get("MAKE_COM_WEBHOOK")
data_to_send = {
"title": title,
"content": content
}
response = requests.post(make_url, json=data_to_send)
if response.status_code == 200:
print("Blog post sent successfully.")
else:
print(f"Failed to send blog post. Status code: {response.status_code}")
except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")
print(f"Data being sent: {data_to_send}")
print(f"Using webhook URL: {make_url}")
Hi @hurmuli, make sure the indentation is correct (use the code below).
Also, are you trying to send an image as part of the data package?
import os
import requests
def send_data_to_wordpress(title: str, content: str):
"""
Send generated blog post to make.com
Args:
title (string): Title of blog post
content (string): Content of blog post
Envs:
MAKE_COM_WEBHOOK (string): Make.com Webhook to connect more services
"""
try:
# Fetch the webhook URL from environment variables
make_url = os.environ["MAKE_COM_WEBHOOK"]
# Check if the environment variable is set
if not make_url:
print("Error: Webhook URL is missing in the environment variables.")
return
# Data to be sent to Make.com
data_to_send = {"title": title, "content": content}
# Send the POST request
response = requests.post(make_url, json=data_to_send)
# Check if the request was successful
if response.status_code == 200:
print("Blog post sent successfully.")
else:
print(f"Failed to send blog post. Status code: {response.status_code}")
except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")
# Debugging information
print(f"Data being sent: {data_to_send}")
print(f"Using webhook URL: {make_url}")
Thanks for the code, I need to check it out but it also seems your editor has a bug which stops users from copy pasting code and delete pasted code. Please fix this ASAP.
I’m a user like you sorry but I can’t fix the tool. If something doesn’t work you should create a post under the bugs section.
However, if you are referring to the top part of the code where the variables are declared that is done automatically for you based on what you create in the input variable area