twilio-node: Twilio.sendMessage, price in response data is null
I used Twilio.sendMessage to send SMS:
Twilio.sendMessage({to: to, from: from, body: message }, function(err, responseData) {
console.log(responseData);
};
Here is the sample of the responseData
: (some fields are masked)
{ sid: 'xxx',
date_created: 'Tue, 20 May 2014 04:34:22 +0000',
date_updated: 'Tue, 20 May 2014 04:34:22 +0000',
date_sent: null,
account_sid: 'xxx',
to: 'xxx',
from: 'xxx',
body: 'xxx',
status: 'queued',
num_segments: '1',
num_media: '0',
direction: 'outbound-api',
api_version: '2010-04-01',
price: null,
price_unit: 'USD',
uri: '/2010-04-01/Accounts/xxx/Messages/xxx.json',
subresource_uris: { media: '/2010-04-01/Accounts/xxx/Messages/xxx/Media.json' },
dateCreated: Tue May 20 2014 12:34:22 GMT+0800 (HKT),
dateUpdated: Tue May 20 2014 12:34:22 GMT+0800 (HKT),
dateSent: null,
accountSid: 'xxx',
numSegments: '1',
numMedia: '0',
apiVersion: '2010-04-01',
priceUnit: 'USD',
subresourceUris: { media: '/2010-04-01/Accounts/xxx/Messages/xxx/Media.json' } }
and the field price
become null
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 19 (2 by maintainers)
I actually have found a few instances where querying immediately after the message has been ‘sent’ (as per the webhook request from Twilio) still results in a null price, so I am just waiting 3 seconds and querying then. I think getting the price in the POST would be an awesome improvement, especially if you guys have that information handy at that point anyway.
Just heard back on the support ticket and was told that it can take up to 24 hours for the price to be available and that a daily cronjob is really the only option for getting the price for messages.
It is worth noting that Kevin’s status callback reference is not entirely of relevance, given that the price itself is nowhere to be found in the webhook request’s body, so one is left with no choice but to query for the price regardless of webhook, which in my opinion is excessively cumbersome.