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:
- 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
-
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.
-
See answer to 1.