Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Q] Is is possible to programmatically register an SMS sender ID #23

Open
AbdBarho opened this issue Aug 30, 2023 · 2 comments
Open

[Q] Is is possible to programmatically register an SMS sender ID #23

AbdBarho opened this issue Aug 30, 2023 · 2 comments

Comments

@AbdBarho
Copy link

AbdBarho commented Aug 30, 2023

Hello, I am using the following code to send an sms, numbers masked for privacy reasons

const client = sipgateIO({ tokenId, token });

createSMSModule(client).send({
    // this number is assigned to my account from employer:
    from: '+49157XXXXXXXX',

    message: 'Test SMS',
    to: 'some other number',
  })

I am getting the following error

Error: Number is not registered as a sender ID in your account

Why do I have to register the sender ID if the mobile number is already assigned to my account?

I can register the number on the Website if I try to send an sms manually, but is it possible to achieve this programmatically?

Looking at the API specs:
https://api.sipgate.com/v2/doc#/sms
it seems that this should be possible, however, it was unclear to me how to achieve this with sipgate-node library.

The sms module only exports these two functions

export interface SMSModule {
    send: (sms: ShortMessage, sendAt?: Date) => Promise<void>;
    getSmsExtensions: (webuserId: string) => Promise<SmsExtension[]>;
}

Do I have to do requests to the API directly without the client?

I suppose I would need to do a request for verification to the number, get the verification code from the sms of the number, and then do a post to verify?

Thank you.

Related #18

@AbdBarho
Copy link
Author

After some more tearing a part in the internals of this library, this is the progress I was able to make:

import { getSmsCallerIds, getUserSmsExtension } from 'sipgateio/dist/sms/sms.js'

const userId = await client.getAuthenticatedWebuserId();
const extension = await getUserSmsExtension(client, userId);
const callerIDs = await getSmsCallerIds(client, userId, extension);
console.log({extension, callerIDs});

which results in

{
  extension: 's70',
  callerIDs: [
    {
      id: 0,
      phonenumber: 'sipgate',
      verified: true,
      defaultNumber: true
    }
  ]
}

This explains why the example on the sipgate io page did not work, because the extension is not 's0' (see #18).

There does not seem to be any code that does the registration / validation of the caller ID.

@AbdBarho
Copy link
Author

AbdBarho commented Aug 30, 2023

The documentation of the API spec does not state anywhere how to authorize if doing HTTP request manually, it is just basic auth:

fetch('https://api.sipgate.com/v2/....', {
  headers: {
        Authorization: `Basic ${Buffer.from(`${tokenId}:${token}`).toString('base64')}}`,
      Accept: 'application/json',
      'Content-Type': 'application/json'
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant