# Setup and Configuration

We require two packages to create a simple client application to receive notifications:\
1\. [socket.io-client](https://www.npmjs.com/package/socket.io-client) (For connectivity)\
2\. HTTP [client-library](https://www.npmjs.com/package/axios) (For HTTP sending requests)

A typical simple application to get notification enabled is as depicted below.\
It's a two-step process.

1. Authentication (/v1/auth) user
2. Listen the specific event to receive relevant message\data\
   -Listen for event the "**notification**" to receive transactional notifications\
   -Listen for event the "**balance**" to receive balance changes\
   -Listen for event the "**history**" to receive history changes

```
const axios = require('axios').default;
const { io } = require('socket.io-client')
            
const relysiaEndpoint = 'api.relysia.com';

(async () => {
    // Login into account
    const loginObject = await axios.post(`https://${relysiaEndpoint}/v1/auth`, {email: "user@abc.com", password: "password"});
    console.log('Login completed', loginObject.data);
    // Connect websocket for this account
    const socket = io(`wss://${relysiaEndpoint}`, {
        extraHeaders: {
            authToken: loginObject.data.data.token,
        },    
        transports: ['websocket', 'polling']
    });

    socket.on('error', function(error) {
        console.log("Connection Error: " + error.toString());
    });

     // Listen for message and log them as notification arrive
    socket.on('notification', function (message) {
        console.log('event received', message);
    })

    // listen for balance and log them on balance arrive
    socket.on('balance', function (balance) {
        console.log('event received', balance);
    })

    // listen for history and log them on history arrive
    socket.on('history', function (history) {
        console.log('event received', history);
    })
    
    

    socket.on('connect', function(connection) {
        console.log('WebSocket Client Connected');
        socket.on('close', function() {
            console.log('echo-protocol Connection Closed');
        });
    });
})()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.relysia.com/realtime-transaction-notification/setup-and-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
