Tuesday, 15 March 2011

salesforce - How to get SMS request via twilio -



salesforce - How to get SMS request via twilio -

i have class can access site url in salesforce. site url "https://somesalesforce.com/smstoapex" , same twilio business relationship sms url class can't called. i have reference this document.the twilio sms url right not how check?the twilio business relationship sms url , salesforce site url same of now.whenever sms came via twilio automatically case createin sandbox.but here not happened.i doing right producer not?.can please help me.how resolve problem.i have checked twilio sms url "https://somesalesforce.com/service/apexrest/smstoapex".which url give both salesforce site url, twilio sms url.

@restresource(urlmapping='/smstoapex') global class smstoapex { static twilioaccount business relationship = twilioapi.getdefaultaccount(); @httppost global static void incomingsms() { // error out system.limitexception if exceed // our daily email limit messaging.reservesingleemailcapacity(1); string expectedsignature = restcontext.request.headers.get('x-twilio-signature'); system.debug('es' + expectedsignature); string url = 'https://' + restcontext.request.headers.get('host') + '/services/apexrest' + restcontext.request.requesturi; map <string, string> params = restcontext.request.params; system.debug('smstoapex========>'+params); // validate signature if (!twilioapi.getdefaultclient().validaterequest(expectedsignature, url, params)) { restcontext.response.statuscode = 403; restcontext.response.responsebody = blob.valueof('failure! rcvd '+expectedsignature+'\nurl '+url/*+'\nheaders'+restcontext.request.headers*/); return; } restcontext.response.responsebody = blob.valueof('ok'); string casefrom = params.get('from'); string caseto = params.get('to'); string casebody = params.get('body'); system.debug('step 4 smstoapex casefrom==>'+casefrom); system.debug('step 5 smstoapex caseto===>'+caseto); system.debug('step 6 smstoapex casebody===>'+casebody); case ca = new case(); ca.subject = 'test smstoapex casefrom'+casefrom; ca.description = 'test smstoapex casebody'+casebody+','+caseto; ca.origin = 'phone'; insert ca; } }

a few things check...

can post url via postman? should @ to the lowest degree error if pass in json... is message making sf , failing there, or never making it, indicate problem url/rest class in sfdc check twilio sms logs - should see result in sms logs either success or failure error code. did set twilio creds in cusom setting in sf? uses them signature check. what sfdc debug logs show you? can view debug logs sites user if set in monitor - debug , search site user.

salesforce twilio apex salesforce-service-cloud url-mapping

No comments:

Post a Comment