Skip to main content

How to enable SMS service

Configuration

Click the profile photo and go to Platform Mgt > Service Integration > SMS Service:

Default Supported SMS Service Providers

Tencent Cloud

  1. Enable Tencent Cloud SMS service
  2. Create domestic SMS templates, and configure them in SMS Service after the templates are approved.

Alibaba Cloud

  1. Enable Alibaba Cloud SMS service
  2. Create domestic SMS templates, and configure them in SMS Service after the templates are approved.

Currently, we only support SMS template configuration for verification codes, which satisfy needs such as registering an account via phone number, binding a phone number to an account, and resetting a password. You only need to configure one of the mentioned service providers. If configured all simultaneously, a provider will be randomly chosen when sending verification codes

Additionally, there are some functions that involve sending custom SMS messages, which cannot be standardized. If you need to enable such functions (e.g. the send SMS node in workflows, inviting users to register via phone number, and phone number verification in public forms), you will need to apply for an account with a third-party SMS service provider, and then integrate it independently or customize development by the technical team. Once this mode is activated, the verification code sending channels of Tencent Cloud and Alibaba Cloud in the Platform Mgt will automatically be disabled.

Self Integration

Integration Steps

  1. Create the configuration file appextensions.json

    For example: /data/hap/script/volume/sms/appextensions.json

    {
    "WebhookUrl": "https://api.yourdomain.com/sms/webhook",
    "WebhookHeaders": {}
    }

    Configuration Parameters

    • WebhookUrl: Required, the API endpoint for receiving SMS messages.
    • WebhookHeaders: Optional, custom request header parameters for authentication and other purposes.
  2. Message Body Specification

    HAP sends JSON data to WebhookUrl via POST with application/json format, containing two message types.

    SMS Message Format

    {
    "Type": 1,
    "Data": {
    "Mobiles": ["Phone number"],
    "Message": "SMS content",
    "Signature": "Signature"
    }
    }

    Mobiles is the list of phone numbers to receive messages.

    Voice Verification Code Format

    {
    "Type": 2,
    "Data": {
    "Mobile": "Phone number",
    "Code": "Verification code"
    }
    }
  3. Mount the configuration file appextensions.json to the microservice container at /usr/local/MDPrivateDeployment/sms/appextensions.json.

    Add the following to the docker-compose.yaml file under the app service's volumes:

    - ./volume/sms/appextensions.json:/usr/local/MDPrivateDeployment/sms/appextensions.json
  4. Restart the service