As an developer, you can integrate with SMS Integrator and send SMS messages from your own app.
Create a Twilio Account
A Twilio account is required to use their SMS sending services. You can sign up for free trial account on their website.
Follow the instructions in the sign up and onboarding process, and once complete, have the follow details ready for the next step.
- Account SID
- Authorization Token
- Twilio Phone No.
If you are using the trial account you will also need the follow:
- A verified number on Twilio.
Set up Business Central for SMS
- Navigate to the SMS Setup page.
- Enter the Account SID, Authorization Token and Outgoing Phone No. (this is your Twilio Phone No.)
- Optionally, enable Queue Outgoing SMS. When enable, this will queue and send SMS messages via a Job Queue. When disable, SMS messages will be sent immediately.
If you have enabled Queue Outgoing SMS, then you will also need to setup a Job Queue Entry with the following details.
Field | Value |
---|---|
Object Type to Run | Codeunit |
Object ID to Run | 16043043 |
Parameter String | OUTGOING |
Recurring Job | Yes |
Run on <day of week> | Specify as required |
Starting/Ending Time | Specify as required |
No. of Minutes between Runs | Specify as required, we recommend 5 to 10 minutes |
During testing we strongly recommend you also enable Test Mode.
- Select Test Mode Enabled.
- Enter the phone number you want all messages to be sent to. If you are using a Twilio trial account, this needs to be a verified number.
Integrating with Your App
First, add SMS integrator as a dependency to your app, the details can be found on the Extension Management page.
Now you are able to queue or send SMS messages using the following function in FSG_SMS_Management
. Whether the message is sent immediately or queue for later depends on your SMS Setup.
/// <summary>
/// Sends or queues an SMS message. Note that this function will commit.
/// </summary>
/// <param name="ToNumber">The recipient phone number in international format of [+][country code][phone number]. Depending on your region, local formats such as the area code might need to be omitted. For example the Australia phone number 0444 123 456 should be formatted as +61444123456</param>
/// <param name="MessageBody">The message body. Please keep in mind that the message service may incur additional charges for long messages or messages with special characters such as emojis.</param>
/// <param name="SourceRecordID">The record the message was sent from. This can be helpful for tracking the context for which the message was sent. Pass a blank record if not applicable.</param>
/// <param name="DestinationRecordID">The record the message was sent to. This can be helpful for tracking the context for which the message was sent. Pass a blank record if not applicable.</param>
procedure SendSMS(ToNumber: Code[15]; MessageBody: Text[1500]; SourceRecordID: RecordId; DestinationRecordID: RecordId)
This is an example of what your code might look like.
procedure SendSMS()
var
SMSManagement: Codeunit FSG_SMS_Management;
BlankRecId: RecordId;
begin
SMSManagement.SendSMS('+61444123456', 'This is a test message', Rec.RecordId, BlankRecId);
end;