Link to home
Start Free TrialLog in
Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America

asked on

c# twilio API - SMS Conversation

Below codes is to call Twilio API and get the sms historical conversation for one phone no. However, it takes over 15 seconds and the total records is actually just 5 conversation.

Have any experts worked with Twilio in the past and know another way to get SMS conversation in a faster mode?
Thanks,



TwilioClient.Init(accountSid, authToken);
            var messages2 = MessageResource.Read().Where(x => x.From.ToString() == fromPhoneNo);
            var messages3 = MessageResource.Read().Where(y => y.To == fromPhoneNo);
            var all = messages2.Concat(messages3).OrderByDescending(z => z.DateCreated);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dirk Strauss
Dirk Strauss
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ITsolutionWizard

ASKER

10 to 20 seconds. That is all the codes.
Do you have the SID? Try Fetching the messages instead.
var message = MessageResource.Fetch("MM800f449d0399ed014aae2bcc0cc2f2ec");

Open in new window

I would think that using an SID to fetch a message would be much faster. Have a look at the Retrieve a Single Message section of the Twilio support documentation. If you're only fetching 5 messages here, this might just be faster.
Thanks but I look for messages that came from one phone no