using System.Text.RegularExpressions;
public static class Program
public static void Main()
string jsonString1 = "{\"object\": \"page\",\"entry\": [{\"time\": 1715133223221,\"id\": \"233913169815794\",\"messaging\": [{\"sender\": {\"user_ref\": \"8117360148293088\"},\"recipient\": {\"id\": \"233913169815794\"},\"timestamp\": \"1527459824\",\"referral\": {\"ref\": \"EXAMPLE_STRING_PAYLOAD\",\"source\": \"https://www.youtube.com/watch?v=8rZ5gE0LVew&list=RDbL5rZdFH3Gc&index=7\",\"type\": \"OPEN_THREAD\",\"ads_context_data\": {\"ad_title\": \"<TITLE_OF_THE_AD>\",\"photo_url\": \"https://buffer.com/library/content/images/2023/10/free-images.jpg>\",\"video_url\": \"https://www.youtube.com/watch?v=8rZ5gE0LVew&list=RDbL5rZdFH3Gc&index=7\",\"post_id\": \"POST_ID\",\"product_id\": \"PRODUCT_ID\"}}}]}}";
string jsonString2 = "{\"object\": \"page\",\"entry\": [{\"time\": 1715133223221,\"id\": \"233913169815794\",\"messaging\": [{\"sender\": {\"user_ref\": \"8117360148293088\"},\"recipient\": {\"id\": \"233913169815794\"},\"timestamp\": \"1527459824\",\"referral\": {\"ref\": \"EXAMPLE_STRING_PAYLOAD\",\"source\": \"https://www.youtube.com/watch?v=8rZ5gE0LVew&list=RDbL5rZdFH3Gc&index=7\",\"type\": \"OPEN_THREAD\",\"referer_uri\": \"<WEBSITE_URL>\"}}]}]}";
string jsonString3 = "{\"object\": \"page\",\"entry\": [{\"time\": 1715133223221,\"id\": \"233913169815794\",\"messaging\": [{\"sender\": {\"user_ref\": \"8117360148293088\"},\"recipient\": {\"id\": \"233913169815794\"},\"timestamp\": \"1527459824\",\"referral\": {\"ref\": \"EXAMPLE_STRING_PAYLOAD\",\"source\": \"https://www.youtube.com/watch?v=8rZ5gE0LVew&list=RDbL5rZdFH3Gc&index=7\",\"type\": \"OPEN_THREAD\"}}]}]}";
string refererUriPattern = "\"referer_uri\":";
string adsContextPattern = "\"ads_context_data\":";
if (Regex.IsMatch(jsonString3, refererUriPattern))
Console.WriteLine("moType: chat_plugin");
else if (Regex.IsMatch(jsonString3, adsContextPattern))
Console.WriteLine("moType: ad");
Console.WriteLine("moType: me");