Response from a auto-action webhook call

kingszg
Posts: 21
Joined: Sat Sep 21, 2019 7:38 am

Response from a auto-action webhook call

Post by kingszg » Wed Nov 13, 2019 10:17 am

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.

annettemorgenroth
Posts: 998
Joined: Sun Jun 30, 2013 8:44 am

Re: Response from a auto-action webhook call

Post by annettemorgenroth » Wed Nov 13, 2019 3:39 pm

No but you could use the API to respond.

kingszg
Posts: 21
Joined: Sat Sep 21, 2019 7:38 am

Re: Response from a auto-action webhook call

Post by kingszg » Wed Nov 13, 2019 4:01 pm

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.

markkinchin
Site Admin
Posts: 906
Joined: Fri Mar 02, 2012 1:43 pm

Re: Response from a auto-action webhook call

Post by markkinchin » Wed Nov 13, 2019 5:58 pm

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

kingszg
Posts: 21
Joined: Sat Sep 21, 2019 7:38 am

Re: Response from a auto-action webhook call

Post by kingszg » Thu Nov 14, 2019 9:14 am

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?

markkinchin
Site Admin
Posts: 906
Joined: Fri Mar 02, 2012 1:43 pm

Re: Response from a auto-action webhook call

Post by markkinchin » Thu Nov 14, 2019 5:41 pm

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.

kingszg
Posts: 21
Joined: Sat Sep 21, 2019 7:38 am

Re: Response from a auto-action webhook call

Post by kingszg » Sat Nov 16, 2019 2:59 pm

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);

markkinchin
Site Admin
Posts: 906
Joined: Fri Mar 02, 2012 1:43 pm

Re: Response from a auto-action webhook call

Post by markkinchin » Thu Nov 21, 2019 10:54 am

offerId has been added to JSON setBooking now, please try again

kingszg
Posts: 21
Joined: Sat Sep 21, 2019 7:38 am

Re: Response from a auto-action webhook call

Post by kingszg » Thu Nov 21, 2019 2:35 pm

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"
}

markkinchin
Site Admin
Posts: 906
Joined: Fri Mar 02, 2012 1:43 pm

Re: Response from a auto-action webhook call

Post by markkinchin » Mon Nov 25, 2019 8:52 pm

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.

Post Reply