Skip to content

Instantly share code, notes, and snippets.

@jeznag
Last active June 14, 2020 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeznag/bdbfe1da438fdb23dbbbb2602e40cdb3 to your computer and use it in GitHub Desktop.
Save jeznag/bdbfe1da438fdb23dbbbb2602e40cdb3 to your computer and use it in GitHub Desktop.
Code for Twilio incoming webhook zoho crm
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