Last active
June 14, 2020 13:37
-
-
Save jeznag/bdbfe1da438fdb23dbbbb2602e40cdb3 to your computer and use it in GitHub Desktop.
Code for Twilio incoming webhook zoho crm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
crmAPIRequestMap = crmAPIRequest.toMap(); | |
body = crmAPIRequestMap.get("body"); | |
try | |
{ | |
body_parts = body.toList("&"); | |
message_body = ""; | |
from_number = ""; | |
message_sid = ""; | |
to_number = ""; | |
for each body_part in body_parts | |
{ | |
if(body_part != null && body_part.startsWith("Body=")) | |
{ | |
values = body_part.toList("="); | |
message_body = values.get(1).replaceAll("\+"," "); | |
} | |
if(body_part != null && body_part.startsWith("MessageSid=")) | |
{ | |
values = body_part.toList("="); | |
message_sid = values.get(1); | |
} | |
if(body_part != null && body_part.startsWith("From=")) | |
{ | |
values = body_part.toList("="); | |
from_number = values.get(1).replaceAll("%2B","+"); | |
} | |
if(body_part != null && body_part.startsWith("To=")) | |
{ | |
values = body_part.toList("="); | |
to_number = values.get(1).replaceAll("%2B","+"); | |
} | |
} | |
twilioMessage = {"from":from_number,"sid":message_sid,"body":message_body,"direction":"inbound","to":to_number}; | |
twiliosmsextension0.process_message(twilioMessage); | |
} | |
catch (e) | |
{ info e; | |
} | |
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response></Response>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment