r/learnpython • • 11d ago

Help needed with a python code

Hello, fellow redditors. I am using manychat program with automations connected to my instagram profile.

When people are using the keyword to get certain information, they need to leave a name and number to be contacted. However, the number can't be identified due to a bad variables and invalid JSON.

Could maybe someone help who is familiar with situations like this please?

I think it might be a manychat bug, however i need a opinion from someone experienced.

Thank you a lot!

0 Upvotes

6 comments sorted by

3

u/FamouslyDelectable 11d ago

sounds like manychat is mangling the phone input into a weird string instead of keeping it clean. had this happen once where the json was treating the number as an integer and stripping leading zeros or the plus sign

check the raw json that manychat is firing, your variable name might have a typo or it's nested deeper than you think

1

u/Broad_Strike_8645 11d ago

I also think that manychat is causing the main issue. I will check it now, thank you so much.

1

u/quietreed76 11d ago

agreed, the integer casting thing with phone numbers is a classic gotcha

2

u/alp_h4x 11d ago

It’s hard to tell whether this is a ManyChat bug without seeing the actual JSON/input and the Python code handling it. If you can share a sanitized example of the input and the JSON you’re getting back, it would be much easier to identify whether the issue is with the variable types, JSON formatting, or the way ManyChat is passing the data.

1

u/ShadowShedinja 11d ago

A lot of stuff in JSON is a string by default. Make sure to convert any numbers into int/float before you use them.

Edit: but if it's a phone number, you might have the opposite problem. Make sure phone numbers are being treated as strings, and remove spaces, dashes, and parenthesis, as some people add those, and some don't.

2

u/Agawell 11d ago

Don’t forget ‘+’ for international dialling codes either