My workflow runs smoothly before but after a week it’s not working. However if I “test” run the bot is responding to my request.
Here’s my trigger:
Event Data: Full HTTP request
HTTP Response: Return HTTP 200 Ok
Here’s my code:
import { axios } from "@pipedream/platform";
export default defineComponent({
//This is configurable in Pipedream panel
props: {
telegramBotToken: {
type: "string",
label: "Telegram Bot Token",
description: "Your Telegram Bot API token",
},
chatId: {
type: "string",
label: "Chat ID",
description: "The ID of the chat to monitor for contract addresses",
},
adminUsername: {
type: "string",
label: "Admin Username",
description: "The username of the admin to tag",
},
},
async run({ steps, $ }) {
const regex = /0x[a-fA-F0-9]{40}/g; //set of strings that matches the ETH pattern
const message = steps.trigger.event.body?.message?.text || "";
const contractAddresses = message.match(regex);
if (contractAddresses && contractAddresses.length > 0) {
const warningMessage = "⚠️Warning: Contract address detected. Please do not post any contract address. \n \n Tagging Admin(s):"; //warning messages
const sendMessageUrl = `https://api.telegram.org/bot${this.telegramBotToken}/sendMessage`;
const deleteMessageUrl = `https://api.telegram.org/bot${this.telegramBotToken}/deleteMessage`;
await axios($, {
method: "POST",
url: sendMessageUrl,
data: {
chat_id: this.chatId,
text: `${warningMessage}\n\n@${this.adminUsername}`,
},
});
for (const address of contractAddresses) {
const deleteMessageId = steps.trigger.event.body.message.message_id;
await axios($, {
method: "POST",
url: deleteMessageUrl,
data: {
chat_id: this.chatId,
message_id: deleteMessageId,
},
}).catch((error) => {
console.error(`Failed to delete message with ID ${deleteMessageId}:`, error.response.data);
});
}
}
},
});