Using Data Formatters to operate with Webhook data
Adrián Brito
#1
Adrián Brito
Hello, I’m facing a big issue and I hope someone can help me out.

When an order is fulfilled in any of our stores, we automatically send a WhatsApp message to the customer. Since we operate with Cash on Delivery (COD), we need to inform the customer of the exact amount they need to pay upon delivery.

The issue arises when an order contains 2 or more products. In these cases, we automatically apply a discount (for example, offers like BOGO or 50% off the 2nd unit), but we can’t retrieve the final amount correctly with Botsailor.

For instance, let’s say a customer places an order for 2 units of a product for 39.99€. If they had purchased only 1 unit, it would cost 29.99€, so there’s a 20€ discount on the second unit. We need to inform the customer that they owe 39.99€, but in the Webhook Response Mapping, we can only access the value 29.99€.

We thought we could solve this using Data Formatters. The logic we want to implement is straightforward:

TOTAL = 29.99€ + 29.99€ - 20€ = 39.99€

We’d like to calculate the final amount using formatters, but I haven’t been able to make it work.

Can anyone help me out with this, please?

Thanks in advance, and I hope I explained the issue clearly.
#2
Kamrul Hasan
Hello Adrián Brito,

Thank you for opening a forum thread to discuss your concern. We appreciate your engagement and the opportunity to assist you.

Unfortunately, the functionality you’re looking for is not currently possible. However, you can use a formatter on the total price to apply a discount. Please note that the formatter does not support adding conditions. If you’d like to deduct a specific amount as a discount, you can set up the formatter to subtract that amount directly from the total price.

If you have any further questions or encounter any other issues, please don’t hesitate to reach out to us. You can contact us via:

📧 Support Ticket
💬 WhatsApp
🌐 Webchat

Thank you for choosing our service. We’re here to help!