Smss

Create engaging workflows for your customers with the ability to send SMS communications to consented Contacts using Openscreen's SDKs.

Openscreen SMS messages are associated with a dynamic QR Code scan. In order to send an SMS, an SMS templates must be created and a valid Contact (containing a phone-number and SMS consent) must exist. An SMS Template is simply a standardized message to be sent upon scan. After the SMS template is created, a user can trigger the SMS to be sent to Contact(s) right after a QR Code is scanned.

Attributes

Create Sms Template By Project Id

Creates a new SMS Template which can be used to send SMS to a Contact upon a scan of a QR Code.

Request Object

Returns

Returns the newly created SMS Template. Throws an error if the projectId is invalid.

1 2 3 4 5 6 const smsTemplate = await os.project(projectId).smsTemplates().create({ body: "Body of the message for {{asset.name}}", smsTemplateName: "firstTemplate", responseUrl: "https://myapp/sms-response", statusUrl: "https://myapp/sms-status", });
{ "entityType": "app.sms-template', "projectId": "a76adcf6-002d-40e0-b156-7f2e2d82733b", "smsTemplateName": "firstTemplate", "body": "Body of the message for {{asset.name}}", "responseUrl": "https://myapp/sms-response", "statusUrl": "https://myapp/sms-status" }

Delete Sms Template By Project Id

Deletes an SMS Template. A valid smsTemplateName must be provided in the request.

Returns

Returns the deleted SMS Template object. Throws an error if the smsTemplate name is invalid.

1 const deleteSMSTemplateByProjectId = await os.project(projectId).smsTemplate(smsTemplateName).delete();
{ "entitiyType": "delete_sms_template_by_project_id.response_body", "projectId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "smsTemplateName": "firstTemplate", "body": "body of the message", "responseUrl": "https://myapp/sms-response", "statusUrl": "httpe://myapp/sms-status" }

Get Sms Template By Project Id

Retrieves details of an SMS Template. A valid projectId and a unique smsTemplateName must be provided in the request.

Returns

Returns the specified SMS Template Object. SMS template name is the unique identifier which can be used to Send SMS. Throws an error if the projectId or smsTemplateName is invalid.

1 const smsTemplatesGet = await os.project(projectId).smsTemplate(smsTemplateName).get();
{ "entityType": "get_sms_template_by_project_id.response_body", "projectId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "body": "Body of the message for {{asset.name}}", "responseUrl": "https://myapp/sms-response", "smsTemplateName": "firstTemplate", "statusUrl": "https://myapp/sms-status" }

Get Sms Templates By Project Id

Retrieves saved SMS templates for a project. A unique projectId must be supplied in the request.

Returns

Returns a list of SMS template objects associated to the projectId. Throws an error if the projectId is invalid.

1 const smsTemplatesGet = await os.project(projectId).smsTemplates().get();
{ "entityType": "get_sms_template_by_project_id.response_body", "projectId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "numberOfSmsTemplates": 2, "smsTemplates": [ { "entityType": "app.sms-template", "created": "2021-11-30T16:57:43.000Z", "projectId": "a76adcf6-002d-40e0-b156-7f2e2d82733b", "smsTemplateName": "firstTemplate", "body": "Body of the message for {{asset.name}}", "responseUrl": "https://myapp/sms-response", "statusUrl": "https://myapp/sms-status" }, { "entityType": "app.sms-template", "created": "2021-12-15T19:33:32.000Z", "projectId": "a76adcf6-002d-40e0-b156-7f2e2d82733b", "smsTemplateName": "secondTemplate", "body": "Body of the message for {{asset.name}}", "responseUrl": "httpe://myapp/sms-response", "statusUrl": "httpe://myapp/sms-status" } ] }

Update Sms Template

Updates the text or the responseUrl in an existing SMS template. Update SMS template overwrites the existing data.

Request Object

Returns

Returns the updated SMS template object. Throws an error if the smsTemplateName is invalid.

1 2 3 4 const smsTemplateUpdate = await os.project(projectId).smsTemplate(smsTemplateName).update({ body: "Updated body", responseUrl: "https://mynewapp/sms-response" });
{ "entityType": "update_sms_template.response_body", "projectId": "a76adcf6-002d-40e0-b156-7f2e2d82733b", "smsTemplateName": "firstTemplate", "body": "Updated body",, "responseUrl": "https://mynewapp/sms-response" }

Send Sms By Scan Id

Sends a message to any Contact using the contactId. The Contact must contain a phone number formatted using the E. 164 International Standard for Phone Numbers.

A user may add the SMS text in the request body, or use a pre-existing SMS template. If a user tries to use both, the SMS template will be used.

Request Object

Returns

Returns details of the SMS object including the status of the SMS. Throws an error if the contactId or the scanId are invalid.

1 2 3 4 5 const sms = await os.scan(scanId).sms().send({ // Only one of SMS Template Name or body are required smsTemplateName: "firstTemplate", contactId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" });
{ "sms": { "body": "Body of the message for {{asset.name}}", "contactId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "created": "2021-10-14T15:35:42.474Z", "delivered": "True", "devlieredAt": "2021-10-14T15:35:42.474Z", "from": "+11234567890", "inbound": "False", "modified": "2021-10-14T15:35:42.474Z", "phone": "+11234567890", "projectId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "smsId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "smsTemplateName": "firstTemplate", "status": "delivered" } }