Crates.io | whatsapp-cloud-api |
lib.rs | whatsapp-cloud-api |
version | 0.5.3 |
source | src |
created_at | 2022-05-21 21:08:43.024557 |
updated_at | 2024-03-13 05:07:56.198039 |
description | Whatsapp Cloud API Rust Client |
homepage | https://github.com/sajuthankappan/whatsapp-cloud-api-rs |
repository | https://github.com/sajuthankappan/whatsapp-cloud-api-rs |
max_upload_size | |
id | 590875 |
size | 35,924 |
Whatsapp Cloud API Rust Client
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