Open ensamblador opened 2 years ago
Hi upon testing I found that meta payload for incomming messages has changed here is a working piece with correct JSON attributes
cloudapi-processExternal/lambda_function.py line 27 ##WhatsApp specific iterations. for entry in event['body-json']['entry']: print("Iterating entry") print(entry) for change in entry['changes']: print("Iterating change") print(change) ## Skipping as no contact info was relevant. if('contacts' not in change['value']): continue systemNumber = change['value']['metadata']['phone_number_id'] name = change['value']['contacts'][0]['profile']['name'] phone = '+' + str(change['value']['messages'][0]['from']) channel = 'whatsapp' ##Define message type messageType = change['value']['messages'][0]['type'] if(messageType == 'text'): message = change['value']['messages'][0]['text']['body'] else: message = 'Attachment' fileType = change['value']['messages'][0][messageType]['mime_type'] fileName = change['value']['messages'][0][messageType].get('filename',phone + '.'+fileType.split("/")[1]) fileId = change['value']['messages'][0][messageType]['id'] fileUrl = get_media_url(fileId,WHATS_TOKEN)
Hi upon testing I found that meta payload for incomming messages has changed here is a working piece with correct JSON attributes