# Twilio

### What is Twilio?

Twilio allows us to send and receive text messages globally using applications like the iX Hello platform.

iX Hello allows for the rapid integration of Twilio Text message service to various voice channels such as Alexa, Lex, Google Assistant, and more.

## Prerequisites

* You need to have an active Twilio account
* Enough balance so you can send messages.
* Configuration
  * Account SID
  * Auth Token
  * Phone Number

Twilio uses two credentials to determine which project an API request is coming from: the Account SID, which acts as a username, and the Auth Token which acts as a password.

To get the required information, Log into your [Twilio Account](https://www.twilio.com/console). If you do not already have a Twilio account, click on Sign Up for free and fill the details as shown below to get a trial account.

&#x20;

<figure><img src="/files/2Y6FBhuEmV7RcGPOcybG" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/0nfYm9KlNw0E1016cfwf" alt="" width="466"><figcaption></figcaption></figure>

&#x20;

You’ll get a confirmation message on your mail, confirm the account and you shall be directed to the Twilio dashboard

&#x20;

<figure><img src="/files/gy0wIbpElwtrImlsaX9a" alt="" width="563"><figcaption></figcaption></figure>

Save the following details from the Twilio dashboard:

1. Account SID
2. Auth Token

The next step is to get a trial number from Twilio so that we can use Twilio SMS and MMS for testing. By default, the trial account has a trial balance which can be used to get the trial numbers.

Click on Get a Trial Number, you’ll be provided an option, select on Choose this number and you’ll receive the confirmation message as shown below:

<figure><img src="/files/SJokDiFTQs9QwtmpOGNU" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/cGC1bEGk6SnBJM9ZpQJz" alt="" width="563"><figcaption></figcaption></figure>

To manage the Phone numbers, click on Phone numbers menu in the left navigation and select options to manage active numbers, released numbers, buying a new number, etc.

<figure><img src="/files/NVbnaeIcxcg2bvm5JiJI" alt="" width="371"><figcaption></figcaption></figure>

If you do not have any Active Number, you can purchase one by clicking on “*Buy a Number*” option available in the same screen in left menu.

## Setup Integration Configuration in iX Hello

Keep record of your Account SID, Auth Token, and Twilio phone number. Go to Connect System on Integration Menu. Click on Add New Connection.

#### **Critical Step for US Numbers: A2P 10DLC Registration**

Due to US carrier regulations, if you are using a US-based 10-digit phone number (10DLC), you **must** register it before it can be used to send messages from an application like iX Hello.

Skipping this step will cause your SMS messages to fail with **Twilio Error 30034 (Message from an Unregistered Number)**, even if your `Account SID` and `Auth Token` are correct.

To complete this required step:

1. **Navigate to Campaigns:** In your Twilio Console, go to the `Regulatory Compliance` section for A2P 10DLC campaigns.
   * **Direct Link:** <https://console.twilio.com/us1/develop/sms/regulatory-compliance/campaigns>
2. **Register a Campaign:** Follow Twilio's process to register a "Brand" (your company) and a "Campaign" (the message use case). For simple testing, a "Low Volume Mixed" or similar starter campaign is often sufficient.
3. **Assign Your Number:** After your campaign is approved, you must assign your new Twilio phone number to it. This is the final step that links your number to an approved messaging purpose.

Only after your number is assigned to an active campaign, you can proceed to the next step of configuring the connection in iX Hello.

&#x20;

<figure><img src="/files/Pw8GyBlNk37hRhxD2Ggf" alt=""><figcaption></figcaption></figure>

Select following:

Integration Category: Custom

Choose Connection: Twilio

<figure><img src="/files/kTYebQejSzcJyBCgO3LL" alt="" width="563"><figcaption></figcaption></figure>

Fill in the details from above steps and click on Validate and Save Settings.

| Configuration | Info                                                                                                                                                                              |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Account Sid   | A unique number that is available on your Twilio account’s Dashboard. This behaves like a username.                                                                               |
| Auth Token    | A long string that is also available on your Twilio account’s Dashboard. This behaves like a password.                                                                            |
| Twilio Number | One of the 10-digit phone number (without +1 and without -) that you have purchased on Twilio and is available at Manage Numbers > Active Numbers section on your Twilio account. |

<figure><img src="/files/dBOB9UeYHm3sjD2iVWqU" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/6Ym2fN4mzaGJwn8JsJlZ" alt=""><figcaption></figcaption></figure>

&#x20;

You can now use the integration to build apps in iX Hello that can use Twilio to send SMS and MMS.

## Create App in iX Hello

On Manage Apps menu under Custom Apps menu in the left navigation, click on New Custom App.

Fill up following details to create app.

Name: Twilio Demo

Custom App Type: Search

Category: Default

Click on Save.

<figure><img src="/files/IADYRABysnjBG6tR6bRs" alt="" width="563"><figcaption></figcaption></figure>

## Create a Data Source

Next step is to create a data source that communicates with the integration created in Step 2.

<figure><img src="/files/r3cTPTMUroSCl9Q03RpY" alt="" width="563"><figcaption></figcaption></figure>

## Create Methods

After the data source has been created, we now have to create methods. iX Hello supports

1. SendTextSMS
2. SendSMSWithMedia

### Send Text SMS

| Parameter | Sample Value | Info                                                                                                                                        |
| --------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| ToNumber  | {{ToNumber}} | The phone number which is going to receive the message.                                                                                     |
| Body      | {{Message}}  | <p>Actual Message Content.</p><p>Note: {{}} represents that the value for these parameters are going to be read from the user as input.</p> |

Fill the following details:

| Parameter             | Info                                                                                                                                                                                                                                                                                                                     |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Method Name           | SendTextSMS                                                                                                                                                                                                                                                                                                              |
| Request Type          | <p>SendTextSMS</p><p>This is the method that you are using</p>                                                                                                                                                                                                                                                           |
| Parameters            | See table above                                                                                                                                                                                                                                                                                                          |
| Result Type           | <p>Record</p><p>It indicates that the method can return a single record.</p>                                                                                                                                                                                                                                             |
| Record JsonPath       | <p>Each method returns data in JSON format. To pick any specific information from the JSON, we need to specify the <em>Record JsonPath</em> so the iX Hello platform will pick that data in consideration while displaying results.</p><p>Example: $.\[\*]</p><p>This selects all the records that is returned.</p>      |
| Empty Result Template | <p>I'm sorry, there was problem delivering your message to {{Input.ToNumber}}. Please try again, How else can I help you?</p><p>Note:</p><p>Anything written in between {{ }} is represented as a JSON field and it’s case-sensitive. Input.\* refers that you are taking that value from the inputs provided above.</p> |
| Result Template       | Your message has been delivered to {{Input.ToNumber}}. How else can I help you?                                                                                                                                                                                                                                          |

<figure><img src="/files/P41swBd6iErswn9jpTIo" alt=""><figcaption></figcaption></figure>

You can now test the method. On the Actions menu, click on Test, provide the parameter value, and click on Method Test . You can observe the return from method in Object tab and the result displayed to user in Result Tab.

<figure><img src="/files/ysoBEaDJZPyZQM0rokNF" alt="" width="563"><figcaption></figcaption></figure>

### Send SMS With Media

| Parametet | Sample Value                                                                                                                                                                | Info                                                    |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| ToNumber  | <p>{{ToNumber}}</p><p>e.g. 6785554967</p>                                                                                                                                   | The phone number which is going to receive the message. |
| Body      | <p>{{Message}}</p><p>e.g. Hello there</p>                                                                                                                                   | Actual Message Content                                  |
| MediaURL  | <p>{{MediaUrl}}</p><p>e.g\[<a href="https://www.ixhello.com/assets/Ix_ProductLogo_Hello_White.png"><https://www.ixhello.com/assets/Ix_ProductLogo_Hello_White.png></a>]</p> | Public URL for the media content.                       |

Fill the following details:

| Parameter             | Info                                                                                                                                                                                                                                                                                                                      |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Method Name           | SendSMSWithMedia                                                                                                                                                                                                                                                                                                          |
| Request Type          | <p>SendSMSWithMedia</p><p>The method that you are using</p>                                                                                                                                                                                                                                                               |
| Parameters            | See table above                                                                                                                                                                                                                                                                                                           |
| Result Type           | <p>Record</p><p>It indicates that the method can return a single record.</p>                                                                                                                                                                                                                                              |
| Record JsonPath       | <p>Each method returns data in JSON format. To pick any specific information from the JSON, we need to specify the <em>Record JsonPath</em> so that the iX Hello platform will pick that data in consideration while displaying results.</p><p>Example: $.\[\*]</p><p>This selects all the records that are returned.</p> |
| Empty Result Template | <p>I'm sorry, there was problem delivering your message to {{Input.ToNumber}}. Please try again, how else can I help you?</p><p>Note:</p><p>Anything written in between {{ }} is represented as a JSON field and is case sensitive.</p>                                                                                   |
| Result Template       | Your message has been delivered to {{Input.ToNumber}}. How else can I help you?                                                                                                                                                                                                                                           |

You can repeat the same method to test the method. The following screen shows a sample response.

<figure><img src="/files/Ec7qutIW85UCXSs8hdZ9" alt="" width="563"><figcaption></figcaption></figure>

## Create Intents

Create Intents corresponding to the methods.

### SendTextSMSIntent

| Details                         |
| ------------------------------- |
| Name: SendTextSMSIntent         |
| Intent Type: Search             |
| Intent Action: Execute Method   |
| DataSource : Twilio DS          |
| Data Source Method: SendTextSMS |

<figure><img src="/files/CfCH0QwUvSE7hCNUDwO1" alt="" width="563"><figcaption></figcaption></figure>

### SensSMSWithMediaIntent

| Details                               |
| ------------------------------------- |
| Name: SendSMSWithMediaIntent          |
| Intent Type: Search                   |
| Intent Action: Execute Method         |
| DataSource : Twilio DS                |
| Data Source Method: SendSMSWithMediaI |

## Create Slots

Slots represent the parameters for the intents. You should create slots of the same exact name as the parameters used in the method. The Slots map to the parameters of the method.

### SendTextSMSIntent

| Details:                                  |
| ----------------------------------------- |
| <ol><li>Name: ToNumber</li></ol>          |
| Slot Order: 0 or 1                        |
| Reprompt message: what’s the phone number |
| Type: Number                              |
| Custom App: Twilio Demo                   |
| Intent: SendSMSWithMediaIntent            |
|                                           |
| <ol start="2"><li>Name: Message</li></ol> |
| Slot Order: 3                             |
| Reprompt message: what’s your message     |
| Type: Full Name                           |
| Custom App: Twilio Demo                   |
| Intent: SendSMSWithMediaIntent            |

### SensSMSWithMediaIntent

| Details:                                                                                                                                                                                                                |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Name: ToNumber                                                                                                                                                                                                          |
| Slot Order: 0 or 1                                                                                                                                                                                                      |
| Reprompt message: what’s the phone number                                                                                                                                                                               |
| Type: Number                                                                                                                                                                                                            |
| Custom App: Twilio Demo                                                                                                                                                                                                 |
| Intent: SendSMSWithMediaIntent                                                                                                                                                                                          |
|                                                                                                                                                                                                                         |
| Name: MediaUrl                                                                                                                                                                                                          |
| Slot Order: 2                                                                                                                                                                                                           |
| Reprompt message: please provide the media url                                                                                                                                                                          |
| Type: Text                                                                                                                                                                                                              |
| Custom App: Twilio Demo                                                                                                                                                                                                 |
| Intent: SendSMSWithMediaIntent                                                                                                                                                                                          |
|                                                                                                                                                                                                                         |
| Name: Message                                                                                                                                                                                                           |
| Slot Order: 3                                                                                                                                                                                                           |
| Reprompt message: what’s your message                                                                                                                                                                                   |
| Type: Full Name                                                                                                                                                                                                         |
| Custom App: Twilio Demo                                                                                                                                                                                                 |
| Intent: SendSMSWithMediaIntent                                                                                                                                                                                          |
| Note: If you have Slots with the same name in different intents of the same app, e.g. Message slot in the example above, make sure that they have the same type. Otherwise you may encounter an error in further steps. |

<figure><img src="/files/CW2JIswKtv855GyCh1SV" alt="" width="563"><figcaption></figcaption></figure>

## Create Utterances

Utterances are the short texts that invoke the intent. You have to define a unique utterance for each method.

1. SendTextSMS

| Details                   |
| ------------------------- |
| Value: send text message  |
| Custom App: Twilio Demo   |
| Intent: SendTextSMSIntent |

<figure><img src="/files/6Ei89yj57phm9gdOWOf9" alt="" width="563"><figcaption></figcaption></figure>

2. SendSMSWithMedia

| Details                         |
| ------------------------------- |
| Value: send multi media message |
| Custom App: Twilio Demo         |
| Intent: SendSMSWithMediaIntent  |

<figure><img src="/files/qw9JPGUDPZzgNYGM8PmQ" alt="" width="563"><figcaption></figcaption></figure>

## Create Input

The next step is to create inputs for the intents. Create Inputs corresponding to every intent. You need to create and manage parameters corresponding to the slots for each intent. For example, in SendTextSMSIntent, there are two slots: “ToNumber” and “Message”. Hence for SendTextSMSInput, you need to create two parameters: “ToNumber” and “Message”. Let us look into the process in the following screens:

1. SendTextSMSInput

<figure><img src="/files/WDhrFwfv9YUBpl23ByvY" alt="" width="563"><figcaption></figcaption></figure>

Click on Manage parameters on the action menu.

<figure><img src="/files/L4wZdYBsKODTPP00700N" alt=""><figcaption></figcaption></figure>

Click on Input Parameters and provide the details as shown below. Make sure to map the Input parameter to the same parameter. Also, be careful of the data type used. It should be similar/ compatible with the data type of the slot.

<figure><img src="/files/UIYdZFVuboKWgnYkK3SY" alt="" width="563"><figcaption></figcaption></figure>

Let’s Add another parameter “Message”.

2. Send SMSWithMediaInput

Repeat the same process for SMSWithMediaIntent. Create Input “SMSWithMediaInput” and create parameters.

Parameter Details:

| Details:                                       |
| ---------------------------------------------- |
| <ol start="1"><li>Name: ToNumber</li></ol>     |
| Slot Order: 0 or 1                             |
| Reprompt message: what’s the phone number      |
| Type: Number                                   |
| Custom App: Twilio Demo                        |
| Intent: SendSMSWithMediaIntent                 |
|                                                |
| <ol start="2"><li>Name: MediaUrl</li></ol>     |
| Slot Order: 2                                  |
| Reprompt message: please provide the media url |
| Type: Text                                     |
| Custom App: Twilio Demo                        |
| Intent: SendSMSWithMediaIntent                 |
|                                                |
| <ol start="3"><li>Name: Message</li></ol>      |
| Slot Order: 3                                  |
| Reprompt message: what’s your message          |
| Type: Text                                     |
| Custom App: Twilio Demo                        |
| Intent: SendSMSWithMediaIntent                 |

## Create a Publish Profile

Once you’ve completed all of the above steps, your app is now ready to be publish to iX Hello supported channels. Let’s set up a publish profile.

| Details:                                                                                                                             |
| ------------------------------------------------------------------------------------------------------------------------------------ |
| External App Name: Twilio Name                                                                                                       |
| App Type: Search                                                                                                                     |
| Channel: Lex                                                                                                                         |
| Skill Invocation: Twilio messaging                                                                                                   |
| Messaging: all of the messages shall be auto populated. You would want to double check and confirm all of the messages are provided. |

Click on Save and you shall see the Publish Profile in the iX Hello portal. Click on the Actions menu and then on Publish to Lex.

Select the appropriate LWA account and click on Publish.

On the resulting screen, ensure that a Success message shows for the publishing steps before clicking “**Test Lex**”. If the Success message not shown, click “Go Back to App Publishing” to fix any issue shown in publishing result.

Once you click on "**Test Lex Bot**", you will be redirected to the App Publishing screen, and the Test Bot will appear at the right corner showing the App name along with the Welcome message.

Query the bot with the utterance "**Send Text Message**". The bot will then ask you to provide "**To-Number**" to whom you would like to send the Text Message. Provide the contact number, for example: type 9985554455. The bot will ask you to provide Text Message. Enter text message and click send. The text message will be sent to the recipient.

&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ixhello.com/ixhc/connections/twilio.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
