## How to Use

1. Make sure you configured an Agent Copilot URL using the following pattern: `https://${AgentCopilotBaseUrl}/?userId=${userId}&sessionId=${sessionId}&URLToken=${URLToken}`. For the configuration details, refer to the [Agent Copilot URL](https://docs.cognigy.com/agent-copilot/configure/overview#agent-copilot-url) section.
2. Pass this URL along with the handover to the human agent.
   - For native integrations, the link is passed automatically.
   - For custom integrations, include the link in your handover configuration.
3. If you work with a voice use case, check the Transfer Node in your Flow.  
4. Configure the Transfer Node:
   1. Fill in the **Transcription Webhook** field with your Agent Copilot URL.
   2. Activate **Enable Copilot**.
   3. Specify the header that carries the UUIValue in the **Copilot Headers Key** field. The default is `X-Custom-Header`. This header will be sent to the Agent Copilot transcription webhook, while the UUIValue is also forwarded via SIP headers when transferring the call to the human agent.

### Secure Access with JWT

You can secure standalone access to Agent Copilot by passing a JWT in the URL. This approach ensures that only authenticated users can open the Agent Copilot workspace.

```
https://${AgentCopilotBaseUrl}/?URLToken=${URLToken}&auth={JWT}
```

Where `auth` is the JWT used for authentication. For the authentication to work, the contact center and Cognigy.AI need to share a 256-bit long JWT secret that is used by the Agent Copilot backend. The contact center integration needs to proceed as follows:

1. Creates values for `userId` and `sessionId`.
2. Uses `URLToken` from the respective Cognigy.AI Endpoint.
3. Reads the JWT secret from an internal storage.
4. Signs a JWT with payload containing the `userId` and `sessionId`.

The Agent Copilot backend proceeds as follows:

1. Checks if the `auth` parameter is passed in the URL.
2. If `auth` is passed, the value is treated as a JWT and the Agent Copilot backend verifies the JWT signature.
3. During the verification of the JWT signature, Agent Copilot decodes the payload of the JWT to retrieve the `userId` and `sessionId` parameters, and reads `URLToken` from the URL query string.

For more information about JWTs, read the [JWT documentation](https://www.jwt.io/introduction).
