Integrate with Short Message Service (SMS)

Updated at:

CloudFlow supports sending text messages to mobile phones using Short Message Service (SMS). This topic describes the sample code, parameters, return values, and supported integration modes for integrating CloudFlow with Short Message Service.

Sample code

The following snippet provides an example of how to integrate CloudFlow with Short Message Service.

Type: StateMachine
Name: MyWorkflow
SpecVersion: v1
StartAt: SendSms
States:
  - Type: Task
    Name: SendSms
    Action: SMS:SendSms
    TaskMode: RequestComplete
    Parameters:
      phoneNumbers: "1505818****"
      signName: the****
      templateCode: SMS_463******
      templateParam:
        code: 12345678
    End: true

The code is explained as follows.

  • Action: The value is set to SMS:SendSms.

  • TaskMode: This parameter supports two integration modes: RequestComplete and WaitForCustomCallback.

  • Name, Description: You can configure a name and description that are relevant to your business.

Parameter descriptions

Parameter Name

Required

Description

Example

phoneNumbers

Yes

The mobile phone number that receives text messages. The format is as follows:

  • Domestic SMS: An 11-digit mobile phone number with or without a prefix such as +, +86, 0086, or 86. Example: 1390000****.

  • International SMS: The country code and the phone number. Example: 852000012****.

You can send text messages to multiple mobile phone numbers. Separate the numbers with commas (,). You can specify up to 1,000 mobile phone numbers. Batch calls may have a slight delay compared to single calls.

1390000****

signName

Yes

The name of the SMS signature. Log on to the Short Message Service console. In the navigation pane on the left, choose Domestic Messages or International/Hong Kong, Macao, and Taiwan Messages. Then, obtain the signature name on the Signature Management tab.

Note

The SMS signature must be added and approved. For more information about SMS signature specifications, see SMS signature specifications.

Alibaba Cloud

templateCode

Yes

The code of the SMS template. Log on to the Short Message Service console. In the navigation pane on the left, choose Domestic Messages or International/Hong Kong, Macao, and Taiwan Messages. Then, view the code on the Template Management tab.

Note

The SMS template must be added and approved. When you send international or Hong Kong, Macao, and Taiwan messages, use an international or Hong Kong, Macao, and Taiwan SMS template.

SMS_15305****

templateParam

No

The actual values for the variables in the SMS template. You can pass multiple parameters. Example: {"name":"Zhang*","number":"1390000****"}.

  • If the JSON object needs to include a line feed, handle it according to the standard JSON protocol.

  • For more information about template variable specifications, see SMS template specifications.

templateParam:
  key1: value1
  key2: value2

Return value description

The response is returned in a JSON object. The following code shows a sample response.

{
    "EntryList":{
        "BizId":"176920698********",
        "Code":"OK",
        "Message":"OK",
        "RequestId":"78FF8E83-E133-545F-8B02-********"
    },
    "Headers":{
        "access-control-allow-origin":"*",
        "access-control-expose-headers":"*",
        "connection":"keep-alive",
        "content-length":"110",
        "content-type":"application/json;charset=utf-8",
        "date":"Wed, 25 Oct 2024 02:45:10 GMT",
        "etag":"1t7zGBmxXHA2QlF2********",
        "keep-alive":"timeout=25",
        "x-acs-request-id":"78FF8E83-E133-545F-8B02-********"",
        "x-acs-trace-id":"a91f039d47eb8a7b8ffd68********""
    },
    "StatusCode":200
}

Execution modes

CloudFlow supports two integration modes with Short Message Service: RequestComplete and WaitForCustomCallback.

RequestComplete

After CloudFlow sends a message to Short Message Service, the task is complete. The return value from the Short Message Service platform is the output of the current node.

WaitForCustomCallback

After a request to send a text message is initiated, the current task is suspended. The workflow continues only after a user calls the ReportTaskSucceeded or ReportTaskFailed API operation to return the execution result.

Use the $Context.Current.TaskToken expression as the callback token to continue the workflow.