/twilio-spring-boot

Spring Boot integration with the Twilio Java SDK

Primary LanguageJavaApache License 2.0Apache-2.0

Twilio Spring Boot

Twilio Spring Boot makes it easy to initialize the Twilio Java SDK using the same Spring Boot configuration idioms you are already used to.

Installation

Gradle

dependencies {
    implementation("io.mateo:twilio-spring-boot-starter:1.0.0")
}
ℹ️

Use the compile configuration for older versions of Gradle.

Maven

<dependencies>
    <dependency>
        <groupId>io.mateo</groupId>
        <artifactId>twilio-spring-boot-starter</artifactId>
        <version>1.0.0</version>
    </dependency>
</dependencies>

Configuration

Configure your Twilio credentials using the following:

Never hardcode your Twilio credentials: https://twil.io/secure
application.properties
twilio.credentials.account-sid=${TWILIO_ACCOUNT_SID}
twilio.credentails.auth-token=${TWILIO_AUTH_TOKEN}
application.yml
twilio:
  credentials:
    account-sid: ${TWILIO_ACCOUNT_SID}
    auth-token: ${TWILIO_AUTH_TOKEN}

If you need to override Twilio’s TwilioRestClient or ListeningExecutorService then simply provide beans of those types:

MyConfiguration.java
import com.google.common.util.concurrent.ListeningExecutorService;
import com.twilio.http.TwilioRestClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
public class MyConfiguration {

    @Bean
    public TwilioRestClient twilioRestClient() {
        // ...
    }

    @Bean
    public ListeningExecutorService listeningExecutorService() {
        // ...
    }
}

Twilio Spring Boot automatically looks for those beans and apply them if they are present.