Hi @martijnpoppen,
First of all thanks for all the hard work you’re doing with your Homey Apps, i actually love using them!
I’d like to suggest adding the ability to delete messages, and here’s why:
I have a smart doorbell that sends a notification to a WhatsApp group consisting of myself, my wife, and my Homey (Homey Pro Bot). The process works as follows:
-
The first message sent is: “Ding dong, someone’s at the door.”, along with a snapshot from the doorbell.
-
Immediately after, the image is sent to OpenAI for analysis.
-
Once the analysis is complete, a second message is posted: “Ding dong, it appears the delivery driver is here with a package for you.”
This results in two messages with the same image—one generic and one more detailed after the AI analysis.
What I would like is for the first message to act as a “Loading State”, and once the image is analyzed, that initial message should be deleted and replaced with the detailed one. This way, only the more informative message remains, avoiding redundancy in the chat.
I’ve reviewed the documentation for the WhatsApp client you’re using, and it does support message deletion.
Thanks for considering this feature!
For the ones interested in the AI Analysis:
async function sendRequest(image, question) {
const url = 'https://api.openai.com/v1/chat/completions';
const headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer redacted',
};
const body = {
model: 'gpt-4o',
messages: [
{
role: 'system',
content: 'you are a computer, that answers questions truthfully and briefly'
},
{
role: 'user',
content: [
{
type: 'image_url',
image_url: {
url: image
}
},
{
type: 'text',
text: question
}
]
}
]
};
try {
const response = await fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(body)
});
const data = await response.json();
console.log(data);
return data.choices[0].message.content; // Return the data if needed for further processing
} catch (error) {
console.error('Error:', error);
return null; // Return null in case of error
}
}
const json = JSON.parse(args[0])
const image = json.image
const question = json.question
// Call the function
const answer = await sendRequest(image, question);
tag("openai_analyze_image_answer", answer)
return answer