twilio-node
twilio-node copied to clipboard
Add Typescript types for SMS Status Callbacks
I'm pretty sure there are no typescript types for SMS Status Callback Webhooks. Could you add this in the future? Thanks!
Hi @emagaram, thanks for posting an issue! Could you specify where this typing is missing? I see that status callbacks for SMS messages are typed as strings here.
I was referring to the HTTP body that the webhook sends. Something like this:
type SMSStatusWebhook = {
SmsSid: string;
SmsStatus: "accepted" | "scheduled" | "queued" | "sending" | "sent";
MessageStatus: string;
To: string;
MessagingServiceSid: string;
MessageSid: string;
AccountSid: string;
From: string;
ApiVersion: string;
};
Ah I see. We'll add this issue to our backlog to be prioritized (internal reference: DI-2383). +1s and comments on the issue summary will help it move up the backlog.
Bumping this, also I defined some types myself in one of my projects where I used Status Callbacks:
export enum OutboundSmsStatuses {
sent = 'sent',
delivered = 'delivered',
undelivered = 'undelivered',
failed = 'failed',
queued = 'queued',
}
export enum InboundSmsStatuses {
receiving = 'receiving',
received = 'received',
}
export interface StatusCallback {
AccountSid: `AC${string}`;
MessageSid: `SM${string}`;
SmsSid: `SM${string}`;
MessageStatus: OutboundSmsStatuses | InboundSmsStatuses;
SmsStatus: OutboundSmsStatuses | InboundSmsStatuses;
From: `+${number}`;
To: `+${number}`;
ApiVersion: `${number}-${number}-${number}`;
}
As you may notice this is using TypeScript's Template Literal Types
There are a few more statuses like 'accepted' and 'scheduled' that I am not sure where to place but this is the gist of it. I am not sure if there are differences in fields' values like SmsSid vs MessageSid, MessageStatus and SmsStatus etc. but that's up to the reviewers
Previously, in v3 MessageStatus
was exported.
Now in v4, is not exported anymore.
There is a reason for that?
https://github.com/twilio/twilio-node/commit/b471067195b2e67d8073d70db6432cb14609fedb#diff-2adf184f135ba5d85051c5b5f187adf3d9eb878362c5a04be926ef951b1ff5afL477
Hi @vinicius73. Thanks for pointing this out. We'll add this issue to our backlog to be prioritized (internal reference: DI-2576). +1s and comments on the issue summary will help it move up the backlog.
In the future, please open a new issue thread so that we can better triage the issue, help to avoid potentially missing your comment, and help track the progress individually from the OP.
And any news about adding Status Callback type, as per the suggestion above or in general?
@PCOffline We have this on our internal backlog (DI-2383).
Thanks @Hunga1
This issue has been added to our internal backlog to be prioritized as it changes generated configuration. +1s on the issue summary will help it move up the backlog (DI-2383).
It would of course be quite nice if Twilio provided types for all the different webhook request bodies, including SMS and Voice. This issue has a common thread with #588 which I see has also been marked as DI-2383
on Twilio's internal backlog.
Can anyone (perhaps @claudiachua) speak to the current status of DI-2383? How far down the backlog is it? I would hope Twilio considers DX a priority. 🙂
Yeah this issue has been stale for over a year. The change is small enough to take a day of work for me, which would include both research about every field and actual code, so I'd assume it'd take even less time for a Twilio employee familiar with the codebase and API.
Hey, @Hunga1, @claudiachua, any updates on this? I don't see a reason why such a small change would take over a year.
Yeah this issue has been stale for over a year. The change is small enough to take a day of work for me, which would include both research about every field and actual code, so I'd assume it'd take even less time for a Twilio employee familiar with the codebase and API.
@PCOffline Would you perhaps have the bandwidth to submit a PR? I wonder if Twilio would take it given the right conditions.
@otowncaleb ill try :)