<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Detect event type in callbacks in Developer Forum</title>
    <link>https://community.sinch.com/t5/Developer-Forum/Detect-event-type-in-callbacks/m-p/15513#M106</link>
    <description>&lt;P&gt;Thank you, Biden. Unfortunately, we don't use WhatsApp-specific callbacks, but we activated the triggers:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;MESSAGE_DELIVERY, MESSAGE_INBOUND, CONVERSATION_START // for the Conversation API&lt;/LI&gt;&lt;LI&gt;WHATSAPP_TEMPLATE_APPROVED, WHATSAPP_TEMPLATE_REJECTED // for the Provisioning API&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;As Sam said we can easily detect the event type between a WHATSAPP_TEMPLATE_APPROVED and WHATSAPP_TEMPLATE_REJECTED event because they have a top-level structure in common.&lt;/P&gt;&lt;P&gt;However, it's very difficult to distinguish a MESSAGE_DELIVERY event from a MESSAGE_INBOUND or a WHATSAPP_TEMPLATE_XXX event based on the payload because they have nothing in common.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that these are very core functions, and my intention is to offer a suggestion for future improvement. For example, adding &lt;A href="https://developers.sinch.com/docs/conversation/callbacks/#validating-callbacks" target="_self"&gt;another custom header&lt;/A&gt; to the request like:&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;x-sinch-webhook-trigger=&amp;lt;trigger_type&amp;gt; //ie: MESSAGE_DELIVERY&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;could be a great help for detection and it shouldn't affect backward compatibility.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;Have a nice day!&lt;/P&gt;&lt;P&gt;Diana&lt;/P&gt;</description>
    <pubDate>Thu, 23 May 2024 08:00:28 GMT</pubDate>
    <dc:creator>dianac</dc:creator>
    <dc:date>2024-05-23T08:00:28Z</dc:date>
    <item>
      <title>Detect event type in callbacks</title>
      <link>https://community.sinch.com/t5/Developer-Forum/Detect-event-type-in-callbacks/m-p/15491#M103</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;we have an integration using Conversation API (WhatsApp channel) and we have subscribed to different callback types: delivery reports, conversations start, message inbound.&lt;/P&gt;&lt;P&gt;Furthermore we are subscribed also to events on templates update of Provisioning api.&lt;/P&gt;&lt;P&gt;All events are configured to being received to the same target url on our platform.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The question is: is there a way to detect the event type?&amp;nbsp;&lt;/P&gt;&lt;P&gt;These events has very different payloads and now we implemented the detect like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if (body contains "message_delivery_report"){

//process events as delivery report

}else if (body contains "direction"){

//process inbound message

} else...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are aware that this isn't a solid way to check the event type, but from what we see we can't bind event types in any other way.&lt;/P&gt;&lt;P&gt;Any suggestions on improvement?&lt;/P&gt;&lt;P&gt;For us having&amp;nbsp; an header specifying the event type, for example, would be great (like shopify webhooks).&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;&lt;P&gt;Diana&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 14:04:16 GMT</pubDate>
      <guid>https://community.sinch.com/t5/Developer-Forum/Detect-event-type-in-callbacks/m-p/15491#M103</guid>
      <dc:creator>dianac</dc:creator>
      <dc:date>2024-05-22T14:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: Detect event type in callbacks</title>
      <link>https://community.sinch.com/t5/Developer-Forum/Detect-event-type-in-callbacks/m-p/15509#M104</link>
      <description>&lt;P&gt;Hello Diana,&lt;BR /&gt;Have you reviewed Sinch Developers portal (&lt;A href="https://developers.sinch.com/" target="_blank"&gt;https://developers.sinch.com/&lt;/A&gt;) -- having Conversation API and WhatsApp documents?&lt;BR /&gt;Please review the following and see if this addresses your ask.&lt;BR /&gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;A href="https://developers.sinch.com/docs/conversation/channel-support/whatsapp/message-support/#receiving-waba-events" target="_blank"&gt;https://developers.sinch.com/docs/conversation/channel-support/whatsapp/message-support/#receiving-waba-events&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;Bipin Patel&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 19:00:29 GMT</pubDate>
      <guid>https://community.sinch.com/t5/Developer-Forum/Detect-event-type-in-callbacks/m-p/15509#M104</guid>
      <dc:creator>Bipin_Patel</dc:creator>
      <dc:date>2024-05-22T19:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Detect event type in callbacks</title>
      <link>https://community.sinch.com/t5/Developer-Forum/Detect-event-type-in-callbacks/m-p/15510#M105</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for reaching out! And thank you, Bipin, for providing these links!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition to the links Bipin provided, I recommend reviewing our &lt;A title="Conversation API callbacks document" href="https://developers.sinch.com/docs/conversation/callbacks/" target="_blank" rel="noopener"&gt;Conversation API callbacks document&lt;/A&gt;. This document indicates that your approach may be the most effective for the Conversation API. There appear to be unique, top-level objects in the payload(s) to which you may map event types. You provided an example of this this in the snippet you shared for a &lt;A title="delivery report callback" href="https://developers.sinch.com/docs/conversation/callbacks/#message-delivery-receipt" target="_blank" rel="noopener"&gt;delivery report callback&lt;/A&gt;:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;if (body contains "message_delivery_report"){

//process events as delivery report

}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the Provisioning API, there appears to be a top-level &lt;CODE&gt;type&lt;/CODE&gt; field in most callbacks. This &lt;CODE&gt;type&lt;/CODE&gt; field denotes the event that triggered the callback. For example, if one of your&amp;nbsp;&lt;A title="WhatsApp templates had its status updated" href="https://developers.sinch.com/docs/provisioning-api/api-reference/provisioning-api/tag/WhatsApp-Templates/#tag/WhatsApp-Templates/operation/TemplatesController_updateTemplate" target="_blank" rel="noopener"&gt;WhatsApp templates had its status updated&lt;/A&gt;, you can receive a callback with the &lt;CODE&gt;type&lt;/CODE&gt; field populated with &lt;CODE&gt;WHATSAPP_TEMPLATE_STATUS_UPDATED&lt;/CODE&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'll reach out to get confirmation on all of this. In the meantime, please let us know if you have any other questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you again!&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 20:36:13 GMT</pubDate>
      <guid>https://community.sinch.com/t5/Developer-Forum/Detect-event-type-in-callbacks/m-p/15510#M105</guid>
      <dc:creator>Sam_Williams</dc:creator>
      <dc:date>2024-05-22T20:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: Detect event type in callbacks</title>
      <link>https://community.sinch.com/t5/Developer-Forum/Detect-event-type-in-callbacks/m-p/15513#M106</link>
      <description>&lt;P&gt;Thank you, Biden. Unfortunately, we don't use WhatsApp-specific callbacks, but we activated the triggers:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;MESSAGE_DELIVERY, MESSAGE_INBOUND, CONVERSATION_START // for the Conversation API&lt;/LI&gt;&lt;LI&gt;WHATSAPP_TEMPLATE_APPROVED, WHATSAPP_TEMPLATE_REJECTED // for the Provisioning API&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;As Sam said we can easily detect the event type between a WHATSAPP_TEMPLATE_APPROVED and WHATSAPP_TEMPLATE_REJECTED event because they have a top-level structure in common.&lt;/P&gt;&lt;P&gt;However, it's very difficult to distinguish a MESSAGE_DELIVERY event from a MESSAGE_INBOUND or a WHATSAPP_TEMPLATE_XXX event based on the payload because they have nothing in common.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that these are very core functions, and my intention is to offer a suggestion for future improvement. For example, adding &lt;A href="https://developers.sinch.com/docs/conversation/callbacks/#validating-callbacks" target="_self"&gt;another custom header&lt;/A&gt; to the request like:&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;x-sinch-webhook-trigger=&amp;lt;trigger_type&amp;gt; //ie: MESSAGE_DELIVERY&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;could be a great help for detection and it shouldn't affect backward compatibility.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;Have a nice day!&lt;/P&gt;&lt;P&gt;Diana&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 08:00:28 GMT</pubDate>
      <guid>https://community.sinch.com/t5/Developer-Forum/Detect-event-type-in-callbacks/m-p/15513#M106</guid>
      <dc:creator>dianac</dc:creator>
      <dc:date>2024-05-23T08:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Detect event type in callbacks</title>
      <link>https://community.sinch.com/t5/Developer-Forum/Detect-event-type-in-callbacks/m-p/15514#M107</link>
      <description>&lt;P&gt;Hello Diana,&lt;/P&gt;
&lt;P&gt;Thank you for your suggestion.&amp;nbsp;We will take your input with our R&amp;amp;D team for future improvement in the service.&lt;BR /&gt;Bipin Patel&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 08:08:15 GMT</pubDate>
      <guid>https://community.sinch.com/t5/Developer-Forum/Detect-event-type-in-callbacks/m-p/15514#M107</guid>
      <dc:creator>Bipin_Patel</dc:creator>
      <dc:date>2024-05-23T08:08:15Z</dc:date>
    </item>
  </channel>
</rss>

