How to: Post to public webhook?

For requests or help with our API
Post Reply
rinse-dental
Posts: 16
Joined: Wed Apr 06, 2022 12:04 pm

How to: Post to public webhook?

Post by rinse-dental » Sat May 14, 2022 10:00 am

Use Case: Send custom email/SMS to patient post visit (thank you, survey, etc.). I use Twilio for customer communication and have created a webhook that listens for an event. Is it possible for Open Dental to post to that webhook when appointment status changes to complete?

It seems API Events and API Subscriptions are designed to solve for this case but I can't seem to get it working. I've tested using https://webhook.site/ and it doesn't appear Open Dental's events are working... or, I'm doing something wrong. :D

SLeon
Posts: 168
Joined: Mon Mar 01, 2021 11:00 am

Re: How to: Post to public webhook?

Post by SLeon » Mon May 16, 2022 12:16 pm

API Events and Subscriptions are indeed how you would go about this. (https://www.opendental.com/site/apisubscriptions.html)

1. Send a Subscriptions POST request similar to below: (Note the trailing '/')

Code: Select all

{
"EndPointUrl": "https://webhook.site/.../",
"WatchTable": "Appointment",
"PollingSeconds": 60
}
2. Send an API request that changes an appointment, such as Appointments PUT Confirm.

3. Wait up to the amount of time specified as "PollingSeconds" to receive back the Event. The JSON will appear the same as if you ran an Appointments GET request.

We were able to successfully use the Webhook.site website as an EndPointUrl. It is worth noting that the returned list will be for any changes made to an appointment, not just AptStatus.

rinse-dental
Posts: 16
Joined: Wed Apr 06, 2022 12:04 pm

Re: How to: Post to public webhook?

Post by rinse-dental » Mon May 16, 2022 12:27 pm

Thanks. 2 clarifying question before I keep trying...
  • Does the change to the appointment need to be from the API or will API Events fire regardless of change type (e.g. user changes apt status in Open Dental vs. API changes apt. status)?
  • Does the endpoint need to be local or in a private network? I'm assuming not; however, webhook.site is an easy way to test and I'm not sure why this wouldn't be working.

SLeon
Posts: 168
Joined: Mon Mar 01, 2021 11:00 am

Re: How to: Post to public webhook?

Post by SLeon » Mon May 16, 2022 1:25 pm

1. The change to the appointment can be done within Open Dental or via the API.

2. The endpoint does not need to be local. We were able to use webhook.site successfully.

It is worth noting that Open Dental has to be running to send the results.

rinse-dental
Posts: 16
Joined: Wed Apr 06, 2022 12:04 pm

Re: How to: Post to public webhook?

Post by rinse-dental » Mon May 16, 2022 2:41 pm

Boom, got it! Thanks!

rinse-dental
Posts: 16
Joined: Wed Apr 06, 2022 12:04 pm

Re: How to: Post to public webhook?

Post by rinse-dental » Tue May 17, 2022 9:31 am

@SLeon - sorry, quick follow-up question. Does the API Event payload batch all events that occurred between the last call and next call? Or, will it send individual payloads for every event?

SLeon
Posts: 168
Joined: Mon Mar 01, 2021 11:00 am

Re: How to: Post to public webhook?

Post by SLeon » Tue May 17, 2022 11:04 am

All appointments that changed since the last poll will be included in a single payload. For example, if five appointments have been changed within the poll interval, then a single payload containing a list of five appointments will be sent.

rinse-dental
Posts: 16
Joined: Wed Apr 06, 2022 12:04 pm

Re: How to: Post to public webhook?

Post by rinse-dental » Wed May 18, 2022 10:43 am

Thanks! Another question... I've set my workstation; however, it appears I get 2, sometimes 3 distinct calls to my hook for each change. The calls appear to be from three different hosts, one from my server and 2 others from what I presume to be other online workstations. I've tried changing my workstation to my Server Name, I've also tried using ComputerNum instead of CompName.

What am I missing?

I have a temp webhook.site up if you need to see the return. https://webhook.site/#!/3b931c01-a087-4 ... 2173c5ea/1

SLeon
Posts: 168
Joined: Mon Mar 01, 2021 11:00 am

Re: How to: Post to public webhook?

Post by SLeon » Wed May 18, 2022 11:01 am

Thank you, I am actively looking into this issue.

SLeon
Posts: 168
Joined: Mon Mar 01, 2021 11:00 am

Re: How to: Post to public webhook?

Post by SLeon » Fri May 20, 2022 1:45 pm

There appeared to be a small issue where more than one workstation could fire a database event. This has been fixed and will be available in version 22.1.32.

Post Reply