How to use Juji API to connect it to mobile App

We were able to test our Juji chatbot using https://github.com/juji-io/cli-client, but we need more information on how to connect Juji to our mobile app that we have through Azure. We looked at https://juji.io/docs/chat/ and have a few questions :

  1. Do we need a subscription for Websocket and GraphQL?
  2. How do we fetch and push data (get and post method) from Juji to our mobile app?
  3. Is there someone we can talk to for support?

Thank you for trying out Juji platform.

  1. Yes, As described in the documentation, the handshake sequence includes the following: 1. first your client needs to obtain a websocketurl using HTTP POST, 2. then the client needs to HTTP GET that url to upgrade the connection to WebSocket protocol, 3. finally, the client needs to make a GraphQL subscription call over WebSocket to respond to the first WebSocket message sent by the server.

Once this sequence of operations are successfully accomplished by your client, the server will push messages to your client automatically.

  1. For pushing data to server, your client needs to send GraphQL calls over the WebSocket connection established above to the server, and the server will push data back to you automatically over WbSocket as well, as indicated above.

  2. For free use, this forum is the venue for support.

We do have dedicated service for paid customers. Please send email to hello@juji.io if you would like to talk to our sales regarding paid service. Or you can subscribe to our paid service online directly right now, before our pricing page is changed soon.

Hi Huahai,

Thank you very much for your email.

I was trying to reach out to you over email.

After going through the GraphQL JUJI API documentation I have the following questions :

  1. How can I get a Websocket protocol to make a GraphQL subscription (how to get a GraphQL subscription).

  2. Do we have free subscription or paid (please share any documentation to follow, if possible).

  3. Could you elaborate or provide more examples on the use of HTTP POST calls to push data to the server.

Looking forward to hearing from you.

Regards,
Aniket Sinha

Hi, Aniket Sinha!

I’m looking forward to be able to fetch data from the server through Websocket and GraphQL, just as you. So, I’m very interested in this subject and in the answers of the Juji support for this topic

Hi There,

Thank you for your email. Did you get any solution on how to fetch data from the server through Websocket and GraphQL or did you hear back from JUJI forum.

Hi!
I stopped using Juji API because there’s little documentation about the GraphQL and websocket, and these are new ‘subjects’ to me, so I was learning them only to acces Juji API. So it wasn’t a practical deal for me…
And I’ve found that the requests were too slow when trying the free version to build a bot, but I don’t know if I was using it correctly

Hi @hyang,

A gentle reminder to share any update on my request.

Regards,
Aniket Sinha

The documentation and the example node.js code give all the information one needs to make a Juji chat client. If you have trouble following the instruction, please tell us which part is unclear so we can improve the documentation.

Regarding your questions:

  1. As the documentation says, the protocol will be upgraded to Websocket when one makes a HTTP GET request on the “websocketUrl” that one obtains by first posting to Juji API. This Url looks like this “wss://juji.ai/api/v1/ws”. You will also get a participationId, which is an UUID.

I assume that you are building a Juji client in a Web browser, which should have a Websocket Javascript object that one can use to do Websocket calls. An example code can be found at https://developer.mozilla.org/en-US/docs/Web/API/WebSocket#examples

For instance:

// Create WebSocket connection.
const socket = new WebSocket('wss://juji.ai/api/v1/ws');

// Connection opened, make a GraphQL subscription to Juji messages
socket.addEventListener('open', function (event) {
    socket.send('subscription {
        chat(input: {
            participationId: "UUID-YOU-OBTAINED-FROM-PREVIOUS-CALL"
        }) {
            role
            text
            type
        }
    }');
});

// Handle the incoming messages, here we just print it out
socket.addEventListener('message', function (event) {
    console.log('Message from server ', event.data);
});

Complete working code for node.js is very similar to these, you should look over the code at: https://github.com/juji-io/cli-client/blob/master/bin/juji-chat

  1. It is free to develop and test, however, only paid subscriptions can be deployed. We normally grant free subscriptions to students and faculty for teaching purposes. Sometimes we also give out free subscription for promotional purpose. Please contact hello@juji.io to discuss your needs.

  2. See answer to 1.

I have updated the Chat API documentation to add more example code for the browser. Please let me know if it helps.

Hi Hyang,

Thank you very much for sharing the code snippet to implement Websocket. That helped building a Juji client in a Web browser.
However, I still could not understand how to connect it to a mobile App.

Could you share details or any example on getting and posting messages using a mobile app.

Thanks,
Aniket Sinha

Hi Aniket,

There are many mobile platforms, which one are you trying to support?

I am working to implement Android and IOS based application.