What API would be the most apropriate?


What I have here is a simple chat app (below only mockup shown)

fn main() {

    let mut ws = WebSocket::new("x.x.x.x:xxxx".parse::<SocketAddr>().unwrap());

    loop {
        match ws.next() {
            (t, WebSocketEvent::Connect) => {
                println!("connected peer: {:?}", t);

            (t, WebSocketEvent::TextMessage(msg)) => {
                for peer in ws.get_connected().unwrap() {
                    if peer != t {
                        println!("-> relaying to peer {:?}", peer);

                        let mssg = WebSocketEvent::TextMessage(msg.clone());
                        ws.send((peer, mssg));
            _ => {}

Using it I can pass my text messages around. Now, what I wanna do is to implement a small AI message response solution (written in python) which is able to talk to someone else on the other side of my chat app instead of me. So my question is how would I do this . Would I try to make some sort of REST API for my chat (any examples ) or would I do it in some other way (some examples) and is it possible to communicate with my chat app via JSON files/objects. I am completely new to this and I would like to have some examples to learn from. Any help ?