I can create a subscription for endpoint event notifications.
“publicationFilter”: “$.publications[?(@.content.state == ‘ringing’)]”
This gives me the ringing events for the endpoint I’m interested in. What if I’m also interested in the idle and connected events? Is there a way to specify multiple matches for the JSON Path in the publicationFilter, or would I have to set up individual notifications for each event type?
You should be able to leave out the publicationFilter entirely and you’ll get all events for the endpoint, but that includes status changes (e.g. available to DND).
If you want to limit to more than one specific event within the same subscription (which is a best practice anyway), you should be able to do that with the OR operator in your regex expression. Now I’m not great at regex, but I think it would look something like this:
"publicationFilter": "$.publications[?(@.content.state == (ringing|idle|connected))]"
I tried that and lots of variations on it, but it doesn’t give me the expected results. Is the expected input here really regex syntax? The documentation for the publicationFilter says “Receive notifications for publications whose content matches this JSON Path.”, while for the methodFilter it says “Receive notifications for publications whose subject matches this regex filter.” Also the “==” bit doesn’t look like regex to me, but I’m not great at regex either. I also found that most incorrect inputs are accepted but don’t give the expected results. This “publicationFilter”: “$.publications[?(@.content.state == ‘ringing’||‘idle’)]” just returns all events for instance. A working example would be great.
Looks like I’m wrong, it’s JSONPath and not regex. This should be what you need:
“publicationFilter”: “$.publications[?(@.content.state== ‘ringing’ || @.content.state == ‘connected’ || @.content.state == ‘idle’)]”
If I had a working example to give you, I would…but if that doesn’t work for any reason I’ll set aside some time to build this out myself, though it will take a few days.
This is what I tried before, but it doesn’t work. The filter expression is accepted without any complaints, but no events are generated. I tried something similar here https://jsonpath.com/ This $.phoneNumbers[?(@.type==‘home’ || @.type==‘iPhone’)] looks the same and works, so the syntax is correct. Could this be a bug with the code behind this? I can image it’s currently expecting a single value instead of a list.
I just had R&D review and test this, and it appears the publicationFilter is valid and should work. Can you change the subjectFilter to “/endpoints/2002” ?
If that fails, please DM me with the accountId you’re using, which cloud the account is on (dev/public), and timestamps for the creation of the subscription and the event that isn’t resulting in a received webhook.
I copied this from your post “publicationFilter”: “$.publications[?(@.content.state== ‘ringing’ || @.content.state == ‘connected’ || @.content.state == ‘idle’)]”. It has different characters than the single quote mark enclosing the state values, almost impossible to see. After replacing these as this publicationFilter”: “$.publications[?(@.content.state== ‘ringing’ || @.content.state == ‘connected’ || @.content.state == ‘idle’)]” it works. The invalid version is accepted without an error, but doesn’t produce any events.
Interesting…When I check the unicode for those characters both of them appear to be the same. Glad you were able to figure it out though! I will provide some feedback to the Notification team around this, we might need better evaluation of these strings so it generates an error instead of accepting invalid characters.