> ## Documentation Index
> Fetch the complete documentation index at: https://docs.raven.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Sending SMS

> A step by step guide to start sending SMS with Raven

## 💬 Steps to start sending SMS

### Step 1. Raven Account Setup

If you have not signed up on Raven yet, please
[sign up for free](https://console.ravenapp.dev/get-started).

You can either use the default App (\<your-account-name\_test>) created on sign up
or create a new one by going to the
[Settings tab](https://console.ravenapp.dev/get-started) in the dashboard. To
know more please check our [platform doc](/platform/apps/apps) on Apps. Collect
your [credentials](/introduction#credentials) (API Key and App ID) as you will
need them in the API to trigger notifications.

<Note>
  If you are sending SMSs in India, TRAI has mandated to register your business,
  headers (sender IDs), and templates on any of the DLT platforms. If you have
  not done this already, you should check the guide on getting the DLT setup
  done.
</Note>

### Step 2. Add an SMS Integration

An Integration is nothing but a provider like Twilio, MessageBird etc. You can
add/remove any provider without having to manage their APIs. Head over to
[Integrations tab](https://console.ravenapp.dev/get-started) in the dashboard
and select SMS. You will see a list of available SMS integrations as shown here:

<img src="https://mintcdn.com/raven/kmn_wV2dGv3NIOgZ/images/sms-integration.png?fit=max&auto=format&n=kmn_wV2dGv3NIOgZ&q=85&s=c80bb7eaf0363a7e08485d6dd0bb0ab6" alt="SMS Integration tab" width="1440" height="744" data-path="images/sms-integration.png" />

At this point, you either would be using your own SMS providers or would be
looking to add a new one.

Once you have added your Integration, you will be able to view it in the Live
tab on the dashboard. You can always add/remove/update any integration without
having to manage any code.

If you do not see the Integration you are looking for, please email us on
[support@ravenapp.dev](mailto:support@ravenapp.dev), and we will add it to the
list.

### Step 3. Create an Event

Events define - which notifications to send, what should the content be and how
to send them. You can manage all this directly from the dashboard without having
to write a single line of code. Check our platform doc on
[Events](/platform/events/events) for more details.

<img src="https://mintcdn.com/raven/kmn_wV2dGv3NIOgZ/images/sms-event.gif?s=28e8564ad50e7d4938379f72abf5a7dd" alt="Creating an event with SMS." width="600" height="303" data-path="images/sms-event.gif" />

To send an SMS, we need to first create an event with SMS enabled. In this
event, we will add the message content and select the integration to send this
SMS with (the integration we added in the previous step). Head over to
[Events tab](https://console.ravenapp.dev/get-started) in the dashboard and
click on the Create Event button.

1. Give a unique name to this event. This name will be used to trigger the event
   in the Send Event API.
2. Select SMS as a channel to send notifications. Also, select the Integration
   that you added earlier in Step 2. If you are using multiple SMS Integrations,
   you can add one as a fallback. Select the "More Options" switch to add
   fallbacks.
3. Create the SMS template. You can add dynamic text to the template like user
   name, invoice number, order id etc., with the handlebar notation, like this
   `{{user_name}}` For more details on SMS templates, encoding, languages etc,
   please check our [SMS Template doc](sms/sms-template).

Your event is created! You will be able to see it in the Events list now.

### Step 4. Trigger the Event

Trigger the Event Now we just need to test if our setup works. Trigger the event
that you created above. You can either do this from the dashboard itself (Go to
Events tab > Click on View Event Button (Eye) > Dialog opens > Click on Test
Event). The other way is to hit the API directly with cURL or Postman. Below is
how the API will look like -

<CodeGroup>
  ```bash curl theme={null}
  curl 'https://api.ravenapp.dev/v1/apps/{{APP_ID}}/events/send' \
  -H 'Authorization: AuthKey {{API_KEY}}' \
  -H 'Content-Type: application/json' \
  --data-raw '{
      "event": "<YOUR_EVENT_NAME>",
      "user": {
          "mobile": "<MOBILE_NO>"
      },
      "data": {
          "user_name": "John Doe"
      }
  }'
  ```

  ```java java theme={null}
  RavenApiClient client = new RavenApiClient(Authorization.of("AuthKey <YOUR_API_KEY>"));
  try {
      var response = client.send(Send.Request.builder()
                  .appId("<YOUR_APP_ID>")
                  .body(SendEventRequest.builder()
                      .event("YOUR_EVENT_NAME")
                      .data(Map.of("name", "Adam"))
                      .user(User.builder().mobile("<MOBILE_NO>").build())
                      .build())
                  .build());
      
      System.out.println(response.getId());
  } catch (SendException e) {
     System.out.println("Failed to send request" + e.getMessage());
  }
  ```

  ```javascript node theme={null}
  const client = new RavenApi.Client({
    authorization: `AuthKey ${YOUR_API_KEY}`,
  });

  const sendEventResponse = await raven.send({
    appId: "<YOUR_APP_ID>",
    _body: {
      event: "YOUR_EVENT_NAME",
      user: {
        mobile: "<MOBILE_NO>",
      },
      data: {
        name: "John Doe",
        date: "01 December 2020",
      }
    },
  });

  if (sendEventResponse.ok) {
    console.log(`The id of the event is ${sendEventResponse.body.id}`);
  } else {
    console.error("Failed to send event", sendEventResponse.error);
  }
  ```
</CodeGroup>

|                   |                                                                                                                  |
| ----------------- | ---------------------------------------------------------------------------------------------------------------- |
| `YOUR_APP_ID`     | App ID of the currently selected App. Go to Settings > App in the dashboard to view.                             |
| `YOUR_API_KEY`    | The Account API Key. Go to Settings > Account in the dashboard to view.                                          |
| `YOUR_EVENT_NAME` | Name of the Event we created above in Step 2.                                                                    |
| `MOBILE_NO`       | Mobile number to which the SMS should be sent to.                                                                |
| `data`            | The data object contains "key": "value" pairs of any dynamic text that you would have added in the SMS template. |

Copy the cURL request and simply hit enter in your terminal.

<Check>Great! You've successfully sent an SMS with Raven. 👍</Check>

### Step 5. Verify in Logs

As a final step, we can verify if everything went well and the notification was
sent. Raven provides a single view of all logs across all channels. You can view
the request payload, the response and the status of the notification sent. You
can check our platform doc on [Logs & Metrics](/platform/logs-and-metrics) for
more details.

Head over to in the [Logs tab](https://console.ravenapp.dev/get-started)
dashboard and click on View icon of the first log entry. You will be able to see
the details of the payload and the status of the notification that you sent.

<img src="https://mintcdn.com/raven/kmn_wV2dGv3NIOgZ/images/timeline-notification.png?fit=max&auto=format&n=kmn_wV2dGv3NIOgZ&q=85&s=d5ee768d85d453fd8c4b9ed575c84239" alt="Timeline of the Notification" width="772" height="485" data-path="images/timeline-notification.png" />

<Check>
  If you were able to successfully receive the SMS, you are all set! 👍 If you
  are facing any issues, please email us on [support@ravenapp.dev](mailto:support@ravenapp.dev)
</Check>
