- Follow the instructions on the main README file in the root directory of this repository.
- Create a Twilio account.
- Copy and paste the following text into a new file titled env created in the folder for this integration.
- Replace PROJECT_ID with your Google Cloud project ID.
- Replace AGENT_ID with your Dialogflow CX agent ID.
- Replace LOCATION with your agent's location code, e.g. "us-central-1."
TWILIO_AUTH_TOKEN = ''
PROJECT_ID = ''
LOCATION = ''
AGENT_ID = ''
LANGUAGE_CODE = ''
- Log in to the Twilio Dashboard.
- Under the "Account Info" section, take the values for Account SID and Auth Token and replace the value for TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN in the .env file.
- Navigate to the Twilio console.
- Under the "Develop" tab, click "Manage," then "Phone Numbers".
- Click "Buy a Number. "Search for a number that has SMS capabilities and buy it.
Additionally, all phone 10DLC numbers will need to be registered with Twilio. If this applies to you, follow this guide to register your new number.
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. Replace PROJECT-ID with your agent’s GCP Project ID.
gcloud builds submit --tag gcr.io/PROJECT-ID/dialogflow-twilio
Deploy your integration to Cloud Run using the following command. Replace PROJECT_ID
with your agent’s GCP project Id, and DIALOGFLOW_SERIVCE_ACCOUNT
with the Service Account which you acquired in the Service Account Setup step of the main README file.
gcloud beta run deploy --image gcr.io/PROJECT_ID/dialogflow-twilio --service-account DIALOGFLOW_SERVICE_ACCOUNT --memory 1Gi
- When prompted for a target platform, select a platform by entering the corresponding number (for example,
1
forCloud 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.
You can view a list of your active integration deployments under Cloud Run in the GCP Console.
- In the "Phone Number" section, go to Active numbers.
- Click on the purchased number.
- 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.
Now simply text the Twilio phone number you registered and your agent will respond.
This integration can be used as a webhook with Twilio to send WhatsApp messages.
- Under Messaging and Try it out, select Send a WhatsApp message
- Follow the prompts to join the sandbox
- Select the Sandbox settings tab
- Fill When a message comes in with the webhook URL given during deployment and select POST for the Method
- Select Save
- Send a message to your WhatsApp number to test the integration.