Skip to content

Commit

Permalink
Updated Twilio (Text Messaging) README
Browse files Browse the repository at this point in the history
  • Loading branch information
svetlanap-Google committed Jan 6, 2020
1 parent d406444 commit b00db5a
Showing 1 changed file with 44 additions and 24 deletions.
68 changes: 44 additions & 24 deletions twilio/README.md
@@ -1,41 +1,61 @@
# Twilio Integration
# Twilio (Text Messaging) Integration

## Setup

### Prerequisites

In order, to setup this integration, you must do the following first:
- Create a [Twilio account](https://www.twilio.com/try-twilio)
- Clone the [git repo](https://OUR_GIT_REPO)
- Follow the instructions on the [main README file](https://github.com/GoogleCloudPlatform/dialogflow-integrations#readme) in the root directory of this repository.
- Create a [Twilio account](https://www.twilio.com/try-twilio).
- Replace the value of __projectId__ in the [server.js file](https://github.com/GoogleCloudPlatform/dialogflow-integrations/blob/03676af04840c21c12e2590393d5542602591bee/twilio/server.js#L32) with your Dialogflow agent’s Project ID.

### Retrieving Credentials

Login to the Twilio [Dashboard](https://www.twilio.com/console). Under Project
Info, you should see your __Account SID__ and __Auth Token__. Copy both of these
and add them to server.js in the twilio folder. To add them properly, set the
constants __accountSid__ and __authToken__ to their respective values.

1. Log in to the Twilio [Dashboard](https://www.twilio.com/console).
2. Under the "Project Info" section, take the values for __Account SID__ and __Auth Token__ and replace the value for __accountSid__ and __authToken__ in the [server.js file](https://github.com/GoogleCloudPlatform/dialogflow-integrations/blob/03676af04840c21c12e2590393d5542602591bee/twilio/server.js#L34-L35) respectively.
![alt text](images/twilio-retrieving-credentials.png)

### Buying a Phone Number

Navigate to the Twilio console. Then click on the __"All product and services"__
button and navigate to Phone Numbers. Then in the menu click
[Buy a Number](https://www.twilio.com/console/phone-numbers/search). Search for
number that has SMS capabilities, and proceed to buy it. Add this number to
server.js in the twilio folder as the phoneNumber constant. Make sure to include
the "+" at the beginning of the number.
1. Navigate to the Twilio console.
2. Click on the "All product and services" button and navigate to "Phone Numbers".
3. Click [Buy a Number](https://www.twilio.com/console/phone-numbers/search). Search for a
number that has SMS capabilities and buy it.
4. Take the phone number and replace the value for __phoneNumber__ in the [server.js file](https://github.com/GoogleCloudPlatform/dialogflow-integrations/blob/03676af04840c21c12e2590393d5542602591bee/twilio/server.js#L33). Include the "+" at the beginning of the number.

![alt text](images/twilio-buying-a-phone-number.png)

### Setup Phone Number
### Deploying the Integration Using Cloud Run

In your local terminal, change the active directory to the repository’s root directory.

Run the following command to save the state of your repository into [GCP Container Registry](https://console.cloud.google.com/gcr/). Replace PROJECT-ID with your agent’s GCP Project ID and PLATFORM with the platform subdirectory name.

```shell
gcloud builds submit --tag gcr.io/PROJECT-ID/dialogflow-PLATFORM
```

Deploy your integration to live using the following command. Replace PROJECT-ID with your agent’s GCP project Id, PLATFORM with the platform subdirectory name, and YOUR_KEY_FILE with the name (not path) of your Service Account JSON key file.

```shell
gcloud beta run deploy --image gcr.io/PROJECT-ID/dialogflow-PLATFORM --update-env-vars GOOGLE_APPLICATION_CREDENTIALS=YOUR_KEY_FILE --memory 1Gi
```

- When prompted for a target platform, select a platform by entering the corresponding number (for example, ``1`` for ``Cloud Run (fully managed)``).
- When prompted for a region, select a region (for example, ``us-central1``).
- When prompted for a service name hit enter to accept the default.
- When prompted to allow unauthenticated invocations press ``y``.
- Copy the URL given to you, and use it according to the README file in the
given integration's folder.

More information can be found in Cloud Run
[documentation](https://cloud.google.com/run/docs/deploying).

You can view a list of your active integration deployments under [Cloud Run](https://console.cloud.google.com/run) in the GCP Console.

### Setting up Phone Number

In the phone number section go to
[Active numbers](https://www.twilio.com/console/phone-numbers/incoming). Click
on the number you purchased. Underneath messaging, add your server's URL to the
__"A message comes in"__ fill-in box. Make sure the first drop down is set to
Webhook and the HTTP method is set to POST. If you are using Google's Cloud Run,
you should be able have gotten your URL after the first deployment. For
instructions on how to deploy, check the main README file.
1. In the "Phone Number" section, go to [Active numbers](https://www.twilio.com/console/phone-numbers/incoming).
2. Click on the purchased number.
3. Underneath "Messaging", take the value for the server URL printed in the console after the completion of the execution of the last command from the above section to the __"A message comes in"__ fill-in box. Set the first drop-down to __Webhook__ and the HTTP method to __HTTP POST__.

![alt text](images/twilio-setup-phone-number.png)
![alt text](images/twilio-setup-phone-number.png)

0 comments on commit b00db5a

Please sign in to comment.