Page 1 of 2

Response from a auto-action webhook call

Posted: Wed Nov 13, 2019 10:17 am
by kingszg
Hello,
I have seen that it is possible to launch http POST requests from in an auto action.

Is it possible to use the response payload from this request to update fields in the bookings or add info-codes?

Many thanks.

Re: Response from a auto-action webhook call

Posted: Wed Nov 13, 2019 3:39 pm
by annettemorgenroth
No but you could use the API to respond.

Re: Response from a auto-action webhook call

Posted: Wed Nov 13, 2019 4:01 pm
by kingszg
Annette, I'm not sure I understand this.

The idea is to have an auto-rule trigger a http POST request as a webhook, that is specific for a booking. This works and it is not a problem.

The http request returns the following response/payload in JSON format.

HTTP 200 OK
{
"invoiceId": "971Ql0EwJV",
"invoiceLink": "http://localhost:8080/obican/invoiceVie ... 971Ql0EwJV",
"jir": "ea71c96703128b8c551cee339e63f565",
"message": "Invoice successfully created",
"zki": "e7392fc1-ddd2-4f90-909d-18d2c10b1011"
}

What I would like to do is to store (part of) the information in the booking within beds24 - for example I would like to add a "jir" info-code and store "ea71c96703128b8c551cee339e63f565" along with that as info-text.

I appreciate the most elegant way to do this is to go through integromat. (I didn't try it, but it will probably work), however I would like to do this independently of integromat to avoid additional complication. What I was wondering is, whether the webhook of the auto-rule actually does what a webhook should do ... act as a reverse API ... i.e. return payload data.

What I cannot see, is how to do this through the API without using integromat.

Re: Response from a auto-action webhook call

Posted: Wed Nov 13, 2019 5:58 pm
by markkinchin
You can use the auto action web hook to send a notification to your server when the auto action triggers.

If you want to then make a change to the booking in Beds24, you would call the API function JSON setBooking (or similar) to make your change.

https://api.beds24.com

Re: Response from a auto-action webhook call

Posted: Thu Nov 14, 2019 9:14 am
by kingszg
Hi Mark,
I understand that.
But this requires an external application (e.g. integromat) to launch the beds24 API request).

I was just wondering whether there isn't a way to avoid that. The auto-action webhook http post request which I'm launching, has the required data already in the payload of the response.

But I understand there is no way to get that done directly?

Re: Response from a auto-action webhook call

Posted: Thu Nov 14, 2019 5:41 pm
by markkinchin
The only way to modify the booking is to have the external application access the API.

If you are using Integromat, I do know some clients have been able to get Integromat to access the Beds24 API to write changes. This function is not built into our Integromat App but Integromat can access generic API's and post JSON data to them.

Re: Response from a auto-action webhook call

Posted: Sat Nov 16, 2019 2:59 pm
by kingszg
Alright, that's what will try, I just wanted to avoid the additional tool just to modify beds24 own content from within beds24 ;-)

There is another issue I ran into when updating beds24 bookings from through the API.

I was able to update every field within a booking - anyway those I tried - BUT: "offerId" . The following pnp snippet runs without a problem and it updates the guestName, butnot the offerId, which stays at "0"

$auth = array();
$auth['apiKey'] = "apiKeyXXX";
$auth['propKey'] = "propKeyXXX";
$data = array();
$data['authentication'] = $auth;
$data['bookId'] = "15498XXX";
$data['offerId'] = "1";
$data['guestName'] = "TestName"
$json = json_encode($data);
$url = "https://api.beds24.com/json/setBooking";
$ch=curl_init();
curl_setopt($ch, CURLOPT_POST, 1) ;
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$result = curl_exec($ch);
echo $result;
curl_close ($ch);

Re: Response from a auto-action webhook call

Posted: Thu Nov 21, 2019 10:54 am
by markkinchin
offerId has been added to JSON setBooking now, please try again

Re: Response from a auto-action webhook call

Posted: Thu Nov 21, 2019 2:35 pm
by kingszg
Mark,
I really love that you guys are always quick on the ball ;-) Thank you very much!

I checked and php/curl does work for offerId now.

Is there a reason, why I can't get the webhook with an auto-action to work for the same:

Code: Select all

url: https://api.beds24.com/json/setBooking
Custom Header: -
Body Data:
{
    "authentication": {
        "apiKey": "apiKeyxxx",
        "propKey": "propKeyxxx"
    },
    "bookId": "[BOOKID]",
    "offerId": "4"
}

Re: Response from a auto-action webhook call

Posted: Mon Nov 25, 2019 8:52 pm
by markkinchin
Are you trying to use the web hook to post directly to the Beds24 API?

If so this is probably nothing to do with the offerId field.

Please start a support ticket and give an affected booking number and the API function, the support team will be able to check the logs for the error.