# Incoming (MT) SMS

### Incoming SMS from the self-service console to the device

To send incoming SMS from self-service console to your **Thing** (IoT device) please follow the bellow mentioned steps:

{% hint style="info" %}
Please note that in order for you to be able to send incoming SMS to your **Thing** (IoT device) the device must be currently enabled and active. Also, this functionality must be enabled in your Monogoto self-service console.
{% endhint %}

1\.      Click **Things** from the sidebar menu.

2\.      Find a Thing that you wish to send SMS to and to press on Thing name to open its Thing Menu.

3\.      Click **Send SMS to Thing**.

![](https://3922449203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0mPxGpottOEfcucXOR%2Fuploads%2FPLWVKdTNFeBPY2NmKe6J%2FSMS.PNG?alt=media\&token=d6b87caf-3b4e-4fb9-9229-f0ae4f617584)

4\.      Enter a name in the **From** field.

5\.      Type a **Message**.

6\.      Click **Send**.

![](https://3922449203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0mPxGpottOEfcucXOR%2Fuploads%2FQ6fk05yQBalVMRvzrT2j%2F2.PNG?alt=media\&token=f610207d-30ea-486e-b02e-e70d9a61a3b7)

{% hint style="info" %}
Please note that some iot devices due to security reasons require you to define whitelist of phone numbers that can send SMS to your iot devices. Therefore, when you want to be able to send SMS to your iot device we would advise you to do the following:

1. Check if your iot device requires you to have a number whitelisted in order for the iot device to accept the SMS. If it does, then please think of a number that you would like to be shown when sending SMS to your iot device.
2. When sending the SMS from portal, please in **FROM** field enter a phone number that you have entered in your iot device whitelist.
3. When entering phone number in **FROM** field, please enter it with country code, without the + or 00 symbols. For example +4420123456789 should be entered as **4420123456789**.
   {% endhint %}

#### SMS status check via the self-service console:

1\.      Click **Things** from the sidebar menu.

2\.      Find a Thing that you wish to check and open its Thing Menu.

3\.      Scroll down to **Events**, they show SIM logs.

4\.      In **Events**, please check the logs for SMS events.

![](https://3922449203-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M0mPxGpottOEfcucXOR%2F-MT1MYk2RZCIrQTOGsP0%2F-MT1Obu0R6yfOXoYN2bp%2FMT%20SMS.png?alt=media\&token=3115d2f4-9bbc-4da8-b964-f2f2d7799a1e)

{% hint style="info" %}
**Success** = SMS message reached recipient successfully.\
**Failure** = SMS message failed to reach recipient, due to some reason. Usually, the reason should be stated in the same Event.
{% endhint %}

###

### Incoming SMS from the API to the device:

To send an SMS from the portal to a single Thing, please use the following request:

```
curl -X POST "https://console.monogoto.io/thing/ThingId_ICCID_<<<_THING_ICCID_>>>/sms" -H "accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer <<<_TOKEN_HERE_>>>" -d "{ \"Message\": \"<<<_SMS_CONTENT_>>>\", \"From\": \"<<<_SENDER_NAME_>>>\"}"
```

{% hint style="info" %}
Please note that the above shown command needs to be replaced with information: \
\&#xNAN;**<<<\_THING\_ICCID\_>>>** - replace with your Monogoto thing ICCID number\
\&#xNAN;**<<<\_TOKEN\_HERE\_>>>** - replace with your token\
\&#xNAN;**<<<\_SMS\_CONTENT\_>>>** - replace with your SMS message content\
\&#xNAN;**<<<\_SENDER\_NAME\_>>>** - replace with sender name you wish recipient to see
{% endhint %}

Example of request:

```
curl -X POST "https://console.monogoto.io/thing/ThingId_ICCID_8912372646888991/sms" -H "accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer eyJhb6IkpXVCJ9.eyJSb2xlIjoiVXN4lclByb2ZpbGVJZF9kZGM2MThhNC0wNTI1LTQ2MmUtYWN3NzhhMGQxYmbSI6Im4zgFkbWluIiwiQ3VzdG9tsbCwiVXNlcklkIjoiVklkXzg5Yj5Y2OGEyUtNDQThhLTEzZjA0MzJhZDE3YyINTAzgZmUtZGI51My00ZjRiLTktN2U5Yjc0ZWU1ZThlIiwiaWNzM3MjI5L2MDY3NTE2Mjl9.99aSLzP7kTgK6TZGW-xalrMu0GkW6viunt3XxbNng" -d "{ \"Message\": \"Hello\", \"From\": \"console\"}"
```

Expected result (showing Thing ID and SMS ID):

```
ThingId_ICCID_8912372646888991_1606995009188_0.4954212857733442
```

{% hint style="info" %}
Please note that some iot devices due to security reasons require you to define whitelist of phone numbers that can send SMS to your iot devices. Therefore, when you want to be able to send SMS to your iot device we would advise you to do the following:

1. Check if your iot device requires you to have a number whitelisted in order for the iot device to accept the SMS. If it does, then please think of a number that you would like to be shown when sending SMS to your iot device.
2. When sending the SMS via API, please replace **<<<\_SENDER\_NAME\_>>>** with a phone number that you have entered in your iot device whitelist.
   {% endhint %}

#### SMS status check via the self-service console:

1\.      Click **Things** from the sidebar menu.

2\.      Find a Thing that you wish to check and open its Thing Menu.

3\.      Scroll down to **Events**, they show SIM logs.

4\.      In **Events**, please check the logs for SMS events.

![](https://3922449203-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M0mPxGpottOEfcucXOR%2F-MT1MYk2RZCIrQTOGsP0%2F-MT1Obu0R6yfOXoYN2bp%2FMT%20SMS.png?alt=media\&token=3115d2f4-9bbc-4da8-b964-f2f2d7799a1e)

{% hint style="info" %}
**Success** = SMS message reached recipient successfully.\
**Failure** = SMS message failed to reach recipient, due to some reason. Usually, the reason should be stated in the same Event.
{% endhint %}

### Incoming SMS via the webhook from self-service console:

Monogoto provides you with an option to receive a duplicate of the incoming SMS to **Thing** (IoT device) via the webhook. Usually, this option is used to inspect the contents of the incoming SMS when the **Thing** (IoT device) is physically not reachable.&#x20;

{% hint style="info" %}
Please note that even if the incoming SMS will fail to be delivered to **Thing** (IoT device), the webhook option would still show what message was supposed to reach the **Thing** (IoT device).
{% endhint %}

<figure><img src="https://3922449203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0mPxGpottOEfcucXOR%2Fuploads%2FMdNIn7IwTRXjbfOmlexy%2Fimage.png?alt=media&#x26;token=cbbd64e1-7ba1-46ba-8d36-ba70bb34de99" alt=""><figcaption></figcaption></figure>

1\.      Login to the Monogoto portal and go to **Things Groups*****.***

2\.      Press on the Edit button in the Thing Group you wish to have Webhook configuration&#x73;**.**

3\.      In the Edit Thing group window, please enter a webhook address in the field **Webhook for incoming SMS.**

![](https://3922449203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0mPxGpottOEfcucXOR%2Fuploads%2Fp8hZGlV6dDSP0m8jijuT%2FMT%20SMS%200.PNG?alt=media\&token=1b543038-285b-4b42-95ba-dac1e73cfe38)

4\.      Scroll down to the bottom of the page and press button **SAVE & CLOSE**.

**Done**. Now when one of your things in this group receives an MT SMS, a webhook will be sent to your entered address.

{% hint style="info" %}
Please note that you may use **Test** button near your entered webhook address to check if your entered address is able to receive webhook from Monogoto portal.
{% endhint %}

{% hint style="warning" %}
In case you need MT SMS not to reach the network destination, but only send a webhook, please mark **terminate incoming SMS message in the webhook**.
{% endhint %}

<figure><img src="https://3922449203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0mPxGpottOEfcucXOR%2Fuploads%2FADTPHVfpUFJaa6ZmKt6R%2FMT%20SMS.PNG?alt=media&#x26;token=2f4a92b8-cd80-4e21-abc7-754d3398e673" alt=""><figcaption></figcaption></figure>

#### SMS status check via the self-service console:

1\.      Click **Things** from the sidebar menu.

2\.      Find a Thing that you wish to check and open its Thing Menu.

3\.      Scroll down to **Events**, they show SIM logs.

4\.      In **Events**, please check if you can see any events about webhooks near the SMS message event.

{% hint style="info" %}
**No event about webhook** = indicates that the webhook was sent successfully.\
**Webhook retry times** = usually indicates that the webhook failed to reach the entered address.
{% endhint %}

Below you can see failed webhook example:

![](https://3922449203-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M0mPxGpottOEfcucXOR%2F-MT1MYk2RZCIrQTOGsP0%2F-MT1OKIN5OuKe6skx34i%2FInbound%20sms%20webhook.png?alt=media\&token=ec6632c5-492c-4a18-b0ff-42ab57f40682)
