Skip to content

Commit bc6b438

Browse files
Update docs
2 parents d11c106 + 2d63179 commit bc6b438

16 files changed

+534
-109
lines changed

docs/.vitepress/config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import shofySidebar from '../shofy/sidebar'
1919
import athenaSidebar from '../athena/sidebar'
2020
import cloudifySidebar from '../cloudify/sidebar'
2121
import homzenSidebar from '../homzen/sidebar'
22+
import smsGatewaySidebar from '../sms-gateway/sidebar'
2223

2324
export default defineConfig({
2425
title: 'Botble Documentation',
@@ -83,6 +84,7 @@ export default defineConfig({
8384
{ text: 'Athena', link: '/athena/'},
8485
{ text: 'Cloudify', link: '/cloudify/'},
8586
{ text: 'Homzen', link: '/homzen/'},
87+
{ text: 'SMS Gateway', link: '/sms-gateway/'},
8688
],
8789
},
8890
{ text: 'Support', link: 'https://botble.ticksy.com' },
@@ -114,6 +116,7 @@ export default defineConfig({
114116
athena: athenaSidebar,
115117
cloudify: cloudifySidebar,
116118
homzen: homzenSidebar,
119+
'sms-gateway': smsGatewaySidebar,
117120
},
118121

119122
socialLinks: [{ icon: 'github', link: 'https://github.com/botble' }],

docs/sms-gateway/extending.md

+175
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# Extending the Plugin
2+
3+
The SMS Gateway plugin for Botble CMS allows you to extend its functionality by adding custom SMS drivers. This guide explains how to create a custom SMS driver by extending the plugin with your own implementation, including setting up a configuration form.
4+
5+
## Overview
6+
7+
To extend the SMS Gateway plugin, you'll need to:
8+
9+
1. **Create a New Driver Class**: Extend the `AbstractDriver` class to define your custom SMS provider.
10+
2. **Implement Required Methods**: Implement the abstract methods and provide additional configuration and functionality.
11+
3. **Create a Configuration Form**: Define a form for configuring the SMS provider settings.
12+
4. **Register Your Custom Driver**: Integrate your custom driver with the SMS Gateway plugin.
13+
14+
## Creating a Custom SMS Driver
15+
16+
### Step 1: Define Your Driver Class
17+
18+
Create a new PHP class that extends the `AbstractDriver` class. This class will implement the specific functionality for your SMS provider.
19+
20+
```php
21+
<?php
22+
23+
namespace FriendsOfBotble\Sms\Drivers;
24+
25+
use Botble\Base\Forms\FormAbstract;
26+
use FriendsOfBotble\Sms\DataTransferObjects\SmsResponse;
27+
use FriendsOfBotble\Sms\Facades\Sms as SmsFacade;
28+
use FriendsOfBotble\Sms\Forms\NexmoGatewayForm;
29+
use Vonage\Client;
30+
use Vonage\Client\Credentials\Basic;
31+
use Vonage\SMS\Message\SMS;
32+
33+
class Nexmo extends AbstractDriver
34+
{
35+
protected Client $client;
36+
37+
public function __construct()
38+
{
39+
$key = SmsFacade::getSetting('key', 'nexmo');
40+
$secret = SmsFacade::getSetting('secret', 'nexmo');
41+
42+
if (empty($key) || empty($secret)) {
43+
return;
44+
}
45+
46+
$this->client = new Client(new Basic($key, $secret));
47+
}
48+
49+
protected function performSend(string $to, string $message): SmsResponse
50+
{
51+
$response = $this->client->sms()->send(
52+
new SMS($to, $this->getFrom(), $message)
53+
);
54+
55+
$message = $response->current();
56+
57+
return new SmsResponse(
58+
success: $message->getStatus() === 0,
59+
messageId: $message->getMessageId(),
60+
response: $response->getAllMessagesRaw(),
61+
);
62+
}
63+
64+
public function getLogo(): string
65+
{
66+
return asset('vendor/core/plugins/sms/images/nexmo.png');
67+
}
68+
69+
public function getInstructions(): string
70+
{
71+
return view('plugins/sms::instructions.nexmo');
72+
}
73+
74+
public function getSettingForm(): FormAbstract
75+
{
76+
return NexmoGatewayForm::create();
77+
}
78+
}
79+
```
80+
81+
### Step 2: Implement Required Methods
82+
83+
- **`performSend(string $to, string $message): SmsResponse`**: Implement the logic for sending an SMS message. This method should interact with the SMS provider’s API and return an `SmsResponse` object.
84+
- **`getLogo(): string`**: Provide the URL to the logo image of your SMS provider. This image will be used in the plugin’s UI.
85+
- **`getInstructions(): string`**: Return a view or string with instructions for configuring the SMS provider.
86+
- **`getSettingForm(): FormAbstract`**: Return a form for configuring the SMS provider settings.
87+
88+
### Step 3: Create a Configuration Form
89+
90+
Define a form for configuring the settings of your SMS provider. This form will be used in the admin panel to set up the provider.
91+
92+
#### Example: Nexmo Gateway Form
93+
94+
```php
95+
<?php
96+
97+
namespace FriendsOfBotble\Sms\Forms;
98+
99+
use Botble\Base\Facades\Html;
100+
use Botble\Base\Forms\FieldOptions\TextFieldOption;
101+
use Botble\Base\Forms\Fields\TextField;
102+
103+
class NexmoGatewayForm extends SmsGatewayForm
104+
{
105+
protected array $sensitiveFields = [
106+
'key',
107+
'secret',
108+
];
109+
110+
public function setup(): void
111+
{
112+
parent::setup();
113+
114+
$this
115+
->add(
116+
'key',
117+
TextField::class,
118+
TextFieldOption::make()
119+
->label(trans('plugins/sms::nexmo.key'))
120+
->required()
121+
)
122+
->add(
123+
'secret',
124+
TextField::class,
125+
TextFieldOption::make()
126+
->label(trans('plugins/sms::nexmo.secret'))
127+
->required()
128+
)
129+
->add(
130+
'from',
131+
TextField::class,
132+
TextFieldOption::make()
133+
->label(trans('plugins/sms::nexmo.from'))
134+
->helperText(trans('plugins/sms::nexmo.from_help', [
135+
'link' => Html::link(
136+
'https://developer.vonage.com/en/messaging/sms/guides/custom-sender-id?source=messaging',
137+
trans('plugins/sms::nexmo.here'),
138+
['target' => '_blank']
139+
),
140+
]))
141+
->required()
142+
);
143+
}
144+
}
145+
```
146+
147+
- **`$sensitiveFields`**: Define sensitive fields that should be protected or masked.
148+
- **`setup()`**: Configure the form fields, including labels, helper text, and validation requirements.
149+
150+
### Step 4: Register Your Custom Driver
151+
152+
To integrate your custom driver with the SMS Gateway plugin, register it in your plugin's service provider.
153+
154+
```php
155+
// In your plugin’s service provider
156+
public function boot()
157+
{
158+
Sms::extend('nexmo', Nexmo::class);
159+
}
160+
```
161+
162+
## Example Usage
163+
164+
Once your custom driver is registered, you can use it as follows:
165+
166+
```php
167+
// Sending an SMS message
168+
Sms::driver('nexmo')->send('+11234567890', 'Your OTP code is: 123456');
169+
```
170+
171+
## Troubleshooting
172+
173+
- **Check Logs**: Review the SMS logs to ensure messages are sent correctly and diagnose any issues.
174+
- **Verify Configuration**: Ensure that your API credentials and settings are correctly configured in the admin panel.
175+
- **Consult Documentation**: Refer to the documentation of your SMS provider for details on API usage and error codes.
Loading

docs/sms-gateway/images/nexmo.png

27.7 KB
Loading
Loading
72.9 KB
Loading
Loading

docs/sms-gateway/images/twilio.png

40.1 KB
Loading

docs/sms-gateway/index.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SMS Gateway Plugin
2+
3+
The SMS Gateway Plugin for Botble CMS integrates with popular SMS services to send SMS messages directly to your users. This plugin is versatile and supports both Twilio and Nexmo services, providing you with a reliable way to reach your customers.
4+
5+
## Features
6+
7+
- **Twilio & Nexmo Support**: Easily configure and use Twilio or Nexmo to send SMS messages.
8+
- **Phone Number Verification**: Verify your customer's phone numbers to ensure accurate delivery.
9+
- **Extendable**: The plugin is designed to be extendable. You can add custom SMS service providers by extending the SMS service.

docs/sms-gateway/installation.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Installation
2+
3+
Follow these steps to install the SMS Gateway Plugin for Botble CMS:
4+
5+
### Download the Plugin
6+
7+
* Purchase and download the plugin package from CodeCanyon.
8+
* Extract the downloaded zip file to your local machine.
9+
10+
### Upload the Plugin
11+
12+
* Connect to your web server using FTP, SFTP, or your preferred method.
13+
* Navigate to the `/platform/plugins` directory of your Botble CMS installation.
14+
* Upload the extracted plugin folder to the `/platform/plugins` directory.
15+
16+
### Activate the Plugin
17+
18+
* Log in to your Botble CMS admin panel.
19+
* Go to **Plugins** in the sidebar menu.
20+
* Find the **SMS Gateway** plugin in the list and click the **Activate** button.
21+
22+
### Configure the Plugin
23+
24+
Once activated, navigate to **SMS Gateway** in the sidebar menu to configure the plugin.
25+
Choose your preferred SMS service (Twilio or Nexmo) and enter the necessary credentials:
26+
27+
* **Twilio**: Account SID, Auth Token, and From Number.
28+
* **Nexmo**: API Key, API Secret, and From Number.
29+
30+
Save the settings.

docs/sms-gateway/logging.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SMS Logs
2+
3+
The SMS Logs feature of the SMS Gateway plugin allows you to monitor and review all SMS messages sent through the system. You can view detailed information about each message, including the provider used, recipient, sender number, message content, time sent, and the raw request and response.
4+
5+
## Accessing SMS Logs
6+
7+
Navigate to **SMS Gateway** -> **SMS Logs** in the admin panel.
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Phone Verification
2+
3+
The **Phone Verification** feature in the SMS Gateway plugin allows you to verify user phone numbers via OTP (One-Time Password). This process ensures the phone numbers provided by users are valid and active.
4+
5+
![Phone Verification](images/phone-verification.png)
6+
7+
## Configuring Phone Verification
8+
9+
1. **Access Phone Verification Settings**:
10+
- Log in to your Botble CMS admin panel.
11+
- Navigate to **SMS Gateway**.
12+
13+
2. **Configure OTP Settings**:
14+
- **Guard**: Specify the guard to be used for OTP verification.
15+
- **OTP Code Expire Time**: Set the expiration time for the OTP code in minutes. The default setting is 5 minutes. This determines how long the OTP code will remain valid before expiring.
16+
- **Phone Verification Requirement**: Enable this option to require users to verify their phone number before they can access the system.
17+
- **OTP Message**: Customize the message sent to users containing the OTP code. Use `{code}` as a placeholder for the actual OTP code.
18+
19+
### Example OTP Message
20+
21+
```plaintext
22+
Your OTP code is: {code}
23+
```
24+
25+
3. **Save Settings**:
26+
- Click **Save settings** to apply the configuration changes.
27+
28+
![Phone Verification Settings](images/phone-verification-settings.png)

docs/sms-gateway/services/nexmo.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Nexmo Integration
2+
3+
The **SMS Gateway Plugin** for Botble CMS integrates with **Nexmo** (Vonage) to enable SMS messaging. Follow these steps to configure Nexmo as your SMS service provider and utilize its features.
4+
5+
![Nexmo](../images/nexmo.png)
6+
7+
## Prerequisites
8+
9+
Before configuring Nexmo, make sure you have:
10+
11+
- A Nexmo account. Sign up at [Nexmo's website](https://www.vonage.com/communications-apis/sms/).
12+
- A verified Nexmo phone number capable of sending SMS.
13+
- Your Nexmo **API Key** and **API Secret**.
14+
15+
## Step 1: Activate and Configure Nexmo
16+
17+
1. **Access the Plugin Settings**:
18+
- Log in to your Botble CMS admin panel.
19+
- Navigate to **SMS Gateway**.
20+
21+
2. **Activate Nexmo as a Service Provider**:
22+
- In the **Service Providers** section, select **Nexmo** from the list.
23+
- Click **Activate** to enable Nexmo as a service provider.
24+
25+
3. **Configure Nexmo Credentials**:
26+
- **API Key**: Enter the API Key from your Nexmo dashboard.
27+
- **API Secret**: Enter the API Secret found in your Nexmo dashboard.
28+
- **From Number**: Enter the Nexmo phone number or sender name from which SMS messages will be sent. Ensure it is correctly formatted according to Nexmo’s requirements.
29+
30+
4. **Save Your Settings**:
31+
- Click **Save** to apply the Nexmo configuration.
32+
33+
![Nexmo Configuration](../images/nexmo-configuration.png)
34+
35+
### Example Configuration
36+
37+
```plaintext
38+
API Key: your_api_key
39+
API Secret: your_api_secret
40+
From Number: +1234567890 or YourCompany
41+
```
42+
43+
## Step 2: Set Nexmo as the Default SMS Provider
44+
45+
1. **Choose the Default Provider**:
46+
- After activating and configuring Nexmo, navigate to the **Default SMS Provider** setting.
47+
- Select **Nexmo** from the dropdown list of activated providers.
48+
49+
2. **Save the Default Provider**:
50+
- Click **Save** to confirm Nexmo as your default SMS provider.
51+
52+
## Step 3: Sending SMS with Nexmo
53+
54+
Once Nexmo is set as the default provider, the SMS Gateway Plugin will use it for all SMS messaging, including verification and notifications.
55+
56+
### Sending a Test SMS
57+
58+
1. In the **SMS Gateway** settings, locate the **Send Test SMS** section.
59+
2. Enter a recipient phone number in international format (e.g., `+11234567890`).
60+
3. Write a test message and click **Send Test SMS**.
61+
4. Verify the delivery of the test SMS on your phone or check the Nexmo logs.
62+
63+
## Troubleshooting
64+
65+
If you encounter issues:
66+
67+
1. **Review Logs**: Check the raw request and response for errors or issues.
68+
2. **Verify Configuration**: Ensure your Nexmo credentials and settings are correct.
69+
3. **Consult Nexmo Documentation**: Refer to [Nexmo's API documentation](https://developer.nexmo.com/messaging/sms/overview) for error codes and troubleshooting tips.
70+
71+
For specific error codes and their resolutions, refer to the Nexmo documentation or contact Nexmo support.

0 commit comments

Comments
 (0)