2 个版本

0.1.1 2023 年 5 月 12 日
0.1.0 2023 年 5 月 12 日

#23 in #api-error

MIT 许可证

26KB
469

sarufi-rs 🦀

一个 Rust 包,帮助您与受 Python Sarufi SDK 启发的 Sarufi 平台交互

安装

cargo add sarufi

身份验证

>>> use sarufi::{Sarufi, ApiError}
>>> let api_key = std::env::var("YOUR_SARUFI_API_KEY")
>>> let api = Sarufi(api_key).unwrap()

创建机器人


async fn test() -> Result<(),ApiError> {

    let name = "My Rusty Chatbot";
    let description = Some("A rusty chatbot created using Sarufi API");
    let industry = Some("Technology");
    let flow: Option<HashMap<String, Value>> = None;
    let intents: Option<HashMap<String, Vec<String>>> = None;
    let webhook_url = Some("https://example.com/webhook");
    let webhook_trigger_intents: Option<Vec<String>> = None;
    let visible_on_community = Some(true);  

    let bot = api.create_bot(
            name,
            description,
            industry,
            flow,
            intents,
            webhook_url,
            webhook_trigger_intents,
            visible_on_community,
    ).await?;

    println!("{:?}", bot);

    Ok(())
    
}

查看 test.rs 文件获取更多示例

依赖关系

~6–19MB
~278K SLoC