Is it possible to relay/forward messages from contact A to contact B using Twilio on WhatsApp?

Viewed 74

I would like to be able to have a single phone number that holds a list of contacts. And then for contact A to be able to send a message to that phone number that looks like this: "Fred: Hi fred!", which would then get relayed by Twilio and sent onward to contact B named Fred like so "Alex said: Hi fred!"

So, is it even possible to relay/forward messages from contact A to contact B using Twilio considering?

If there is what would be an indicated way to go about this in python?

1 Answers

Yes, this is absolutely possible :) In this scenario, you need a Twilio number that acts as a "Man in the middle" and forwards all messages. There is a blog post that describes almost the scenario you mentioned. The only difference is that this sample will use the phone number instead of a contact name before the colon.

+1 415 12341234: Hi, how  are you doing?
+1 415 56785678: Good, any you?


Instead of
Fred: Hi, how  are you doing?
Alex: Good, any you?

But it shouldn't be too hard to use a JSON object that maps names and phone numbers inside the Twilio function. If you want to go the extra mile, you could probably use an API to sync your contacts as well. But that only works if your address book/ contacts app has an API.

Related