Webhook Block inside the chatbot builder
under review
C
Clayton Aires
Hi All!
I would like to suggest that we implement a block that works similar to the trigger block on the chatbot builder. However it will be fired when other system sends json data for a specific url.
So we can parse and handle that data and perform actions on the chatobot, or update customer´s information.
Thanks
Clayton Aires
Kornel Kathi
under review
A
Alla
Please describe in more detail what you mean.
We have a "trigger" block with which we can call any other chatbot block. If we need to pass some data, then we can use the Update clients method before calling the trigger. So I understand this task as a duplicate of the existing functionality
C
Clayton Aires
Alla: It´s a webhook block... we create a webhook feature for sending data to other system on the whatsapp shop.
Let´s suppose that other system has the same webhook feature and we want to receive the json data, proccess it using handler and use it on the chatbot / clients.
In this case we need a block on the chatbot builder (that will work similar to trigger´s block) however it will be activated when the other system sends json data via our webhook url.
So we will get this data from a webhook accesss the values using a handler and perform some action on the chatbot.
Bellow a image showing how it´s suppose to work.
Webhook link: generated automatically by our system (need to be unique to work similar triggers)
Token: Some system allow to insert a custom token to give the data more securety. It also should be created by our system... or randonly by a user.
Bellow some exemples of how other system sends information using webhooks.
C
Clayton Aires
We also can use this for sending information for another system.
A
Alla
Clayton Aires:
I discussed this problem with the programmer.
It is not clear to us what problem this functionality should solve. Try to explain what exactly you need with an example. Also, try to explain why trigger does not suit you?
When using webhooks, it is necessary to understand how the chatbot will understand which client is calling it. The question is that the system works in such a way that we immediately need to understand which customer it is, so describe how we need to identify the customer.
C
Clayton Aires
Alla: Trigger does not suit for this for two reasons:
1- When a system sends information to another via webhook, the o ther system sends all json data. But trigger requires some data like, phone number and the trigger name. In this case we cannot insert these two objects on the other system, because we cannot edit webhook data (it´s generated automatically from the other system, similar our order from whatsapp shop´webhook).
If we can pass the trigger name just on the url to address the trigger name, maybe it can be adapted.
2- We cannot use the handler on the trigger, so we cannot get the json data send to the other system through the webhook.
The main idea here is have a url where the other system can send json data. This url should be unique and allow to handle that data on variables for using on the chatbot.
Trigger API call has default data, the phone_number and the trigger name, that´s why it can´t be used.
Example:
I would like to be notifield about the payment status on stripe:
1- I create a url on botatende.
2- Configure this url on stripe webhook
3- Any time a payment status is modifeld, stripe will send a json data to that url - this data can contain customer information, phone, email, etc.
4- I receive the json data with the paymet status updated
5- Handle the json data
6- Update the contact or send a message based on the received data
Bellow the stripe documentation for this:
Clayton Aires
C
Clayton Aires
Alla: Example 2:
We have the order webhook feature on oficial whatsapp shop for sending the shop´s order´s data to other system, where we ask for a webhook url for sending the order´s json data.
Let´s suppose that I wan´t to send the order webhook json from BotAtende to Promptchat and update customer information based on the order received. See img webhook1.
How can promptchat handle that json data?
Currently I think we cannot get that json data in no way.
If we have some feature, please let me know.
We need just a way to generate this unique url for receiving the json data from other system. After that be able to get info from json using the handler and perform some chatobt action or update contact info.
C
Clayton Aires
Alla: Example 3 - Real situation
I have a payment gateway where I can configure a webhook url for the following updates:
Description
Webhook for billing
Webhook for Invoices
Webhook for Invoices
Webhook for transfers
Webhook to pay bills
Webhook to pay bills
Webhook for anticipations
Webhook for mobile recharge
So if I click on one of these option and configure it, it will ask the config on the image (webhook-billing).
As you can see it has a url that every update on the billing from any customer will be notifield via json data to the other system. In this case it is notifiying astromenbers a video streaming plataform for botatende´s trainning courses, that I use.
On astromenber we can configure a webhook for receiving the data see "webhook config astromembers" screenshot.
Once you configure it, every billing status change that accurs in the payment gateway, will be sent via a post API call with customer data to the astromembers system.
Astromembers uses this info for controling the client´s access to the platform. If the status is payed it give the access or the contrary...
Example of JSON to be received [POST]The notification consists of a POST containing a JSON, as shown in this example:
{
"event":"PAYMENT_RECEIVED",
"payment":{
"object":"payment",
"id":"pay_080225913252",
"dateCreated":"2021-01-01",
"customer":"cus_G7Dvo4iphUNk",
"subscription":"sub_VXJBYgP2u0eO", //somente quando pertencer a uma assinatura
"installment":"2765d086-c7c5-5cca-898a-4262d212587c", //somente quando pertencer a um parcelamento
"paymentLink":"123517639363", //identificador do link de pagamento
"dueDate":"2021-01-01",
"originalDueDate":"2021-01-01",
"value":100,
"netValue":94.51,
"originalValue":null,
"interestValue":null,
"description":"Pedido 056984",
"externalReference":"056984",
"billingType":"CREDIT_CARD",
"status":"RECEIVED",
"pixTransaction":null,
"confirmedDate":"2021-01-01",
"paymentDate":"2021-01-01",
"clientPaymentDate":"2021-01-01",
"installmentNumber": null,
"creditDate":"2021-02-01",
"estimatedCreditDate":"2021-02-01",
"invoiceUrl":"https://www.asaas.com/i/080225913252",
"bankSlipUrl":null,
"transactionReceiptUrl":"https://www.asaas.com/comprovantes/4937311816045162",
"invoiceNumber":"00005101",
"deleted":false,
"anticipated":false,
"anticipable":false,
"lastInvoiceViewedDate":"2021-01-01 12:54:56",
"lastBankSlipViewedDate":null,
"postalService":false,
"creditCard":{
"creditCardNumber":"8829",
"creditCardBrand":"MASTERCARD",
"creditCardToken":"a75a1d98-c52d-4a6b-a413-71e00b193c99"
},
"discount":{
"value":0.00,
"dueDateLimitDays":0,
"type":"FIXED"
},
"fine":{
"value":0.00,
"type":"FIXED"
},
"interest":{
"value":0.00,
"type":"PERCENTAGE"
},
"split":[
{
"walletId":"48548710-9baa-4ec1-a11f-9010193527c6",
"fixedValue":20,
"status":"PENDING",
"refusalReason": null
},
{
"walletId":"0b763922-aa88-4cbe-a567-e3fe8511fa06",
"percentualValue":10,
"status":"PENDING",
"refusalReason": null
}
],
"chargeback": {
"status": "REQUESTED",
"reason": "PROCESS_ERROR"
},
"refunds": null
}
}
So I was asking if we were able to have a webhook block that will work similar to astromembers webhook (that creates a custom urls for receiving data)
And when we receive this data we can use a handler to get, for example the customer ID, payment status, payment link and store it on a variable, on the above case is "customer":"cus_G7Dvo4iphUNk", "status":"PENDING" and "invoiceUrl":"https://www.asaas.com/i/080225913252" respectively.
On a second step we can also, use the customer ID, for getting additional data like, name, phone_number via an get API call and send a message on the whatsapp:
Hi @name!
Your order is with a @status status
Please, make a payment to procced with your order using the bellow link.
@payment_link
It´s all!
I hope it helps to clarify how important a webhook block is. Because it´s just a simple example, but all the system uses this for sendig a bunch of different information. And currently we cannot get data from a webhook, losing a lot of flexibility and application possibilities.
If you have any further question, please let me know.