Implementation Guide

Integrating deep links for direct user communication and room access in TextRP involves dynamically constructing URLs that utilize the Matrix protocol's capabilities. Hereā€™s how you can generate these deep links:

Generating Deep Links to Users:

function createUserDeepLink(walletAddress) {
  const serverDomain = 'synapse.textrp.io';
  return `https://app.textrp.io/#/user/@${walletAddress}:${serverDomain}`;
}

Generating Deep Links to Rooms:

function createRoomDeepLink(roomIdentifier) {
  const serverDomain = 'synapse.textrp.io';
  const roomPrefix = roomIdentifier.startsWith('!') ? 'room/' : 'room/#';
  return `https://app.textrp.io/#/${roomPrefix}${roomIdentifier}:${serverDomain}`;
}

To use these functions, simply pass the wallet address or room ID/alias to the respective function. This will return a string containing the complete deep link which can be used in your application to redirect users directly to the desired chat or room in TextRP.

EXAMPLE

In this scenario, we have a website featuring an NFT, and we want to provide a "Contact Seller" button. When clicked, this button uses the NFT owner's wallet address to create a deep link for direct messaging in TextRP. Below is an example implementation:

HTML Sample with NFT Owner Contact Feature:

<!DOCTYPE html>
<html>
<head>
    <title>NFT Marketplace</title>
</head>
<body>
    <h2>NFT Details</h2>
    <!-- Display NFT Information -->
    <img src="path_to_nft_image.jpg" alt="NFT Image">
    <p>NFT Name: Awesome NFT</p>
    <p id="nftOwner">Owner Wallet Address: rExampleOwnerWalletAddress</p>
    <button onclick="contactSeller()">Contact Seller</button>

    <script>
        function contactSeller() {
            var ownerWalletAddress = document.getElementById('nftOwner').innerText.split(': ')[1];
            var contactLink = `https://app.textrp.io/#/user/@${ownerWalletAddress}:synapse.textrp.io`;
            window.location.href = contactLink;
        }
    </script>
</body>
</html>

In this HTML:

  • The NFT's image and details are displayed.

  • The contactSeller() function retrieves the NFT owner's wallet address from the page (in this case, hardcoded for demonstration purposes) and constructs a deep link for messaging the seller in TextRP.

  • Clicking the "Contact Seller" button will direct the user to a TextRP chat with the NFT owner.

This approach seamlessly integrates the ability to contact an NFT owner directly from an NFT marketplace or gallery website.

Best Practices

  • Ensure the wallet addresses and room IDs are accurate and correspond to the intended recipient or room.

  • Encode URL parameters to handle special characters and spaces where necessary.

  • Test each deep link to confirm it directs to the correct location within the TextRP app.

By adhering to this guide, developers can effectively incorporate deep links into their services, facilitating direct and efficient access to TextRP's messaging features.

Last updated