23 releases

0.5.3 Mar 13, 2024
0.5.2 Feb 21, 2024
0.4.9 Feb 19, 2024
0.4.3 Jan 29, 2024
0.1.6 May 22, 2022

#626 in Web programming

Download history 45/week @ 2024-01-27 31/week @ 2024-02-03 3/week @ 2024-02-10 465/week @ 2024-02-17 155/week @ 2024-02-24 26/week @ 2024-03-02 179/week @ 2024-03-09 29/week @ 2024-03-16 4/week @ 2024-03-23 40/week @ 2024-03-30 15/week @ 2024-04-06 12/week @ 2024-04-13 132/week @ 2024-04-20 3/week @ 2024-04-27

163 downloads per month

MIT/Apache

28KB
833 lines

whatsapp-cloud-api   Latest Version Docs

Whatsapp Cloud API Rust Client

Features

  • Sending messages using Whatspp Cloud API
  • Get / Upload media
  • Models to help processing incoming webhooks

Usage example

Send template based text message

let access_token = "<access_token>";
let phone_number_id = "<phone_number_id>";
let to = "<to>";
let template_name = "hello_world";
let language = "en_US";
let template = Template::new(template_name, language);
let message = Message::from_template(&to, template, None);
let client = WhatsppClient::new(&access_token, &phone_number_id);
client.send_message(&message).await?;

Send template based text message with parameters

let access_token = "<access_token>";
let phone_number_id = "<phone_number_id>";
let template_name = "sample_shipping_confirmation";
let language = "en_US";
let parameters = Vec::from([Parameter::from_text("3")]);
let components = Vec::from([Component::with_parameters("body", parameters)]);
let template = Template::with_components(template_name, language, components);
let message = Message::from_template(&to, template, None);
let client = WhatasppClient::new(&access_token, &phone_number_id);
let response = client.send_message(&message).await?;

Send text message (Note: This requires an user initial conversation)

let access_token = "<access_token>";
let phone_number_id = "<phone_number_id>";
let to = "<to>";
let text = Text::new("test message");
let message = Message::from_text(&to, text, None);
let client = WhatasppClient::new(&access_token, &phone_number_id);
client.send_message(&message).await?;

For more details, please see the tests folder

Dependencies

~4–16MB
~247K SLoC