#### don't forget to add comments, specially for hard coded part def send_whatsapp(mediaURL, paramsArray, lang, uid, phoneNumber, whitelabel): import requests import traceback try: if uid == "TCXcp5VIsfhHZrh0nm2VsgBtcGy2": phoneNumber = None # paramsArray[0] = userName # phoneNumber = "6366026267" phoneNumber = phoneNumber.split(",") phoneNumber = phoneNumber[0] phoneNumber = str(phoneNumber) userName = paramsArray[0] if userName is None: if lang == "en": userName = "Farmer" else: # for hi & else userName = "किसान" if lang == "hi": campaignName = "Main Campaign Hindi May 2023" elif lang == "kn": campaignName = "Main Campaign Kannada" elif lang == "mr": campaignName = "Main Campaign Marathi" elif lang == "gu": campaignName = "Main Campaign Gujarati" elif lang == "pa": campaignName = "Main Campaign Punjabi" elif lang == "ta": campaignName = "Main Campaign Tamil" elif lang == "te": campaignName = "Main Campaign Telugu" elif lang == "ml": campaignName = "Main Campaign Malayalam" else: campaignName = "Main Campaign English May 2023" # campaignName = 'Main Campaign 4' url = "https://backend.aisensy.com/campaign/t1/api" pg_campaign_names = { 'hi': 'Main Campaign Hindi 1', 'en': 'Main Campaign English 1', 'mr': 'Main Campaign Marathi 1' } pg_api_key = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY1NzQ2ZmEwYzg0NjBjNTk5NjhhNzcwYSIsIm5hbWUiOiJUZWNoIFZpc2l0IElUIFB2dC4gTHRkLiIsImFwcE5hbWUiOiJBaVNlbnN5IiwiY2xpZW50SWQiOiI2Mzg5NzA0ZTA2MmE0NzcyMGVjM2I3NWYiLCJhY3RpdmVQbGFuIjoiTk9ORSIsImlhdCI6MTcwMjEyOTU2OH0.YxhKlTJWEi2L0-QKdhEtT4WWzo5WeFbW-Jmko7SI2AI' farmonaut_api_key = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYzODk3MDRlMDYyYTQ3NzIwZWMzYjc2NCIsIm5hbWUiOiJGYXJtb25hdXQgVGVjaG5vbG9naWVzIFB2dC4gTHRkLiIsImFwcE5hbWUiOiJBaVNlbnN5IiwiY2xpZW50SWQiOiI2Mzg5NzA0ZTA2MmE0NzcyMGVjM2I3NWYiLCJhY3RpdmVQbGFuIjoiQkFTSUNfVFJJQUwiLCJpYXQiOjE2Njk5NTE1NjZ9.sm6bFj27KhdOPL7t_aAbLIJW7Il4pMSnLIQ7unVzenM' if whitelabel == None or "farmonaut" in whitelabel: campaignName = 'Payment Successful October' api_key = farmonaut_api_key elif whitelabel == "precisiongrow": campaignName = pg_campaign_names.get('hi','Main Campaign English 1') api_key = pg_api_key # split_name_phone = paramsArray[1].split(",") # try: # phoneNumber = split_name_phone[1] # except: # phoneNumber = '6366026267' # phoneNumber = phoneNumber.replace(" ","") # if "+91" not in phoneNumber: # phoneNumber = "+91" + phoneNumber # if uid == "XSzwRsmzu4OeCm8UvllGn7xsnOk1": # #phoneNumber = "+919819984575" # return # if uid == "TCXcp5VIsfhHZrh0nm2VsgBtcGy2": # phoneNumber = "7893726963" # #phoneNumber = "6366026267" # if uid == "4IeKHcqffiPIuHDHv2PrnthG4sO2": # phoneNumber = "9380316450" # main_obj = {'apiKey': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYzODk3MDRlMDYyYTQ3NzIwZWMzYjc2NCIsIm5hbWUiOiJGYXJtb25hdXQgVGVjaG5vbG9naWVzIFB2dC4gTHRkLiIsImFwcE5hbWUiOiJBaVNlbnN5IiwiY2xpZW50SWQiOiI2Mzg5NzA0ZTA2MmE0NzcyMGVjM2I3NWYiLCJhY3RpdmVQbGFuIjoiQkFTSUNfVFJJQUwiLCJpYXQiOjE2Njk5NTE1NjZ9.sm6bFj27KhdOPL7t_aAbLIJW7Il4pMSnLIQ7unVzenM', # 'campaignName': 'Sample New', # 'destination': '9958983308', # 'userName': 'Nepal Singh', # 'media': {'url': 'https://farmonaut.page.link/EKYC', 'filename': 'Analysis.png'}, # 'templateParams': ['Nepal Singh', 'Nepal Singh, 9229766654', 'N, E', 'W, SE', 'https://farmonaut.page.link/RRMb']} myobj = { "apiKey": api_key, "campaignName": campaignName, "destination": phoneNumber, "userName": userName, "media": {"url": mediaURL, "filename": "Analysis.png"}, "templateParams": paramsArray, } print(myobj) x = requests.post(url, json=myobj) except: print("sendWhatsappErr " + traceback.format_exc())