twilio-agnostic
twilio-agnostic
as a twilio-rs
fork that uses isahc to be async runtime agnostic. It is a Rust library for integrating with Twilio that tries to present an idiomatic Rust interface for making requests to the Twilio API, and validating, parsing, and replying to webhooks that Twilio makes to your server.
First, you'll need to create a Twilio client:
let client = new;
Now, you can use that client to make or receive Twilio requests. For example, to send a message:
client.send_message.await;
Or to make a call:
client.make_call.await;
Of course, much of our interaction with Twilio is by defining resources that respond to Twilio webhooks. To respond to every SMS with a customized reply, in your server's handler method:
use ;
async
Alternatively, to respond to a voice callback with a message:
use ;
async
Using the respond_to_webhook
method will first authenticate that the request came from Twilio, using your AuthToken. If that fails, an error will be sent to the client. Next, the call or message will be parsed from the parameters passed in. If a required field is missing, an error will be sent to the client. Finally, the parsed object will be passed to your handler method, which must return a Twiml
that will be used to respond to the webhook.