11/12/2023 0 Comments Send sms message apiSend a message to the contacts in these contact lists. Note, the contact IDs should be separated by commas. Need at least one from contacts, lists or phones. The Custom fields from the contacts will be filled by the selected template. It may contain any UTF-8 characters ( Note: not all cell phone operators support UTF-8 characters). Just like the other parameters, this should be urlencoded. We need to initialize the Nexmo node library we installed earlier, in the index.The message text. Let’s replace the contents of the file we created earlier. When you send a message with the API, the data about the message status gets sent to the status URL. When a message is coming to the Messages API, the data about the message is sent to the inbound URL. ![]() Use the ngrok URL you got in the previous step and fill in the fields, appending /webhooks/status and /webhooks/inbound, for the respective fields. We’ll use the private key to authenticate our library calls later on. Applications work on a public / private key system, so when you create an application, a public key is generated and kept with Nexmo, and a private key is generated, not kept with Nexmo, and returned to you via the creation of the application. We’ll create one using the Nexmo Dashboard, and that needs a name, and inbound URL and a status URL. Think of applications more like containers, metadata to group all your data on the Nexmo platform. To interact with the Messages API, we’ll need to create a messages application on the Nexmo platform to authenticate our requests. If the status of the message is 0, the SMS was sent successfully, otherwise, the error data for the message is on the error-text property of the message.īecause my text has an emoji in it, I’m setting the type unicode in the options object, otherwise, that emoji is going to be sent on the network as ?.Īfter ngrok runs, it will give you a random-looking URL, that we’ll use as the base for our Webhooks later on. In most cases, it’s going to be 1 element in that array, but if the SMS was longer than 160 characters, it gets split into a multipart SMS, and then the array contains data about each part sent. The response data contains an array for all the messages that were sent, with information about their status. It also accepts a callback that gets called when the API request is done. The method takes as parameters 3 strings and an object: the Nexmo number from which to send the SMS, the phone number where to deliver the SMS, the text of the message and options for the SMS encoding. The Nexmo library has a method for sending the SMS with the SMS API, and that’s. You can find those on the “Getting Started” page in the Nexmo Dashboard. Replace the values in there with your actual API key and secret. ![]() Just use the defaults for init, and then install the nexmo Node.js package.Įnter fullscreen mode Exit fullscreen mode The SMS API is the first Nexmo API, and we’ll use it to send an SMS message to your phone number.įirst off, initialize an NPM package, otherwise, older versions of NPM will complain about installing a package without having a package.json first.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |