<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vlad Bartusica</title>
    <description>The latest articles on DEV Community by Vlad Bartusica (@vladbdev).</description>
    <link>https://dev.to/vladbdev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F630830%2Fb1c31aa2-9934-4ac0-ac45-8dd92f9784a5.jpg</url>
      <title>DEV Community: Vlad Bartusica</title>
      <link>https://dev.to/vladbdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vladbdev"/>
    <language>en</language>
    <item>
      <title>How to ensure that contact information can't be shared in a TalkJS chat</title>
      <dc:creator>Vlad Bartusica</dc:creator>
      <pubDate>Wed, 19 May 2021 18:59:48 +0000</pubDate>
      <link>https://dev.to/talkjs/how-to-ensure-that-contact-information-can-t-be-shared-in-a-talkjs-chat-5dp2</link>
      <guid>https://dev.to/talkjs/how-to-ensure-that-contact-information-can-t-be-shared-in-a-talkjs-chat-5dp2</guid>
      <description>&lt;p&gt;With the &lt;a href="https://talkjs.com" rel="noopener noreferrer"&gt;TalkJS chat API&lt;/a&gt; you can easily add 1-on-1, group and live stream chat to your website. With any imaginable chat or messaging use case, some users will always try to share contact information or links to different websites. We've got you covered: using our solution you can easily restrict some or all contact info and allow or block any other phrases or URLs you want.&lt;/p&gt;

&lt;p&gt;This way you can ensure a safe and secure environment for your users, decreasing the possibility of losing them to an alternative communication channel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdecluttersolutions%2Fimage%2Fupload%2Fv1621449371%2Ftalkjs%2Fcontact-info%2Fchat-contact-info_v6tamw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdecluttersolutions%2Fimage%2Fupload%2Fv1621449371%2Ftalkjs%2Fcontact-info%2Fchat-contact-info_v6tamw.jpg" alt="Contact info"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For this guide we'll consider you setup your app and your users can already exchange messages. If you are new to using TalkJS, make sure to visit our &lt;a href="https://talkjs.com/docs/" rel="noopener noreferrer"&gt;Getting Started&lt;/a&gt; guide. &lt;/p&gt;

&lt;h2&gt;
  
  
  Disable sharing contact information and links
&lt;/h2&gt;

&lt;p&gt;In some situations you might want to suppress all contact information shared by your users. Based on your use case, you might also want to allow some chat participants to share some links or contact info.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a support agent should be allowed to share a link with a customer&lt;/li&gt;
&lt;li&gt;exhibitors or streamers might want to promote their website or external resources, but prevent attendees from sharing their information with everyone&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  TalkJS User Roles
&lt;/h3&gt;

&lt;p&gt;For flexibility, TalkJS allows you to define multiple&lt;a href="https://talkjs.com/docs/Reference/Concepts/Roles.html" rel="noopener noreferrer"&gt;&lt;code&gt;Roles&lt;/code&gt;&lt;/a&gt; that can be assigned to your users to control different settings for the user groups, including text/contact information suppression.&lt;/p&gt;

&lt;p&gt;You can easily create and modify &lt;code&gt;Roles&lt;/code&gt; in the &lt;a href="https://talkjs.com/dashboard/" rel="noopener noreferrer"&gt;TalkJS Dashboard&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdecluttersolutions%2Fimage%2Fupload%2Fv1621449371%2Ftalkjs%2Fcontact-info%2Fdashboard-roles_e5hzbk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdecluttersolutions%2Fimage%2Fupload%2Fv1621449371%2Ftalkjs%2Fcontact-info%2Fdashboard-roles_e5hzbk.jpg" alt="Default Roles"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The role configuration page has a dedicated section &lt;code&gt;Suppress contact info&lt;/code&gt; that allows you to choose one of the following modes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do not suppress contact info: &lt;em&gt;no suppression&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Suppress contact info in all messages: &lt;em&gt;the sender will also see the contact info suppressed in his view&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Only suppress contact info in messages written by others: &lt;em&gt;only the sender will see the contact info&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After you make a selection and save the role, you'll need to assign a role to a user when you create it. Even if the role is named &lt;code&gt;default&lt;/code&gt;, you will still need to assign it in your code.&lt;/p&gt;

&lt;p&gt;Remember to also update the role value in your code if you update the name in the dashboard.&lt;/p&gt;

&lt;p&gt;For the REST API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://api.talkjs.com/v1/YOUR_APP_ID/users/12081 &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Authorization: Bearer YOUR_SECRET_KEY"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-X&lt;/span&gt; PUT &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{ "name":"Alice", "email": ["alice@example.com"], "photoUrl": "https://demo.talkjs.com/img/alice.jpg", "welcomeMessage": "Hey there! How are you? :-)", "role": "default" }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the JavaScript Chat SDK:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;me&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Talk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;123456&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;alice@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;photoUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://demo.talkjs.com/img/alice.jpg&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;welcomeMessage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hey there! How are you? :-)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;default&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="c1"&gt;// &amp;lt;-- that's the one!&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Suppression options
&lt;/h3&gt;

&lt;p&gt;By default, enabling any of these modes will suppress the contact information shared by the chat participants. This section will now feature some options to give you more control.&lt;/p&gt;

&lt;h4&gt;
  
  
  Allowed hostnames
&lt;/h4&gt;

&lt;p&gt;The section allows you to define multiple whitelisted domains. If you want to allow all links, you can use &lt;code&gt;*&lt;/code&gt;. Some additional usages include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;only some top level domains: &lt;code&gt;*.&amp;lt;tld&amp;gt;&lt;/code&gt; (&lt;code&gt;*.co&lt;/code&gt;, &lt;code&gt;*.nl&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;your website - domain and email (you will need two entries): &lt;code&gt;yourwebsite.com&lt;/code&gt; and &lt;code&gt;*.yourwebsite.com&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdecluttersolutions%2Fimage%2Fupload%2Fv1621449371%2Ftalkjs%2Fcontact-info%2Fallowed-hostnames_gc3hqa.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdecluttersolutions%2Fimage%2Fupload%2Fv1621449371%2Ftalkjs%2Fcontact-info%2Fallowed-hostnames_gc3hqa.jpg" alt="Allowed hostnames"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Allowed phone numbers
&lt;/h4&gt;

&lt;p&gt;You can define individually multiple phone numbers users can share. This actually matches the suffix of the phone number and ignores the punctuation. For example, if you will pass &lt;code&gt;869&lt;/code&gt;, it will allow all phone numbers ending with &lt;code&gt;869&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;040-2475869&lt;/li&gt;
&lt;li&gt;+31 04.02.47.58.69&lt;/li&gt;
&lt;li&gt;0031 40 247 5869&lt;/li&gt;
&lt;li&gt;+31 (0)40-2475869&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To be more precise, you can set the value to &lt;code&gt;402475869&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdecluttersolutions%2Fimage%2Fupload%2Fv1621449371%2Ftalkjs%2Fcontact-info%2Fallowed-phone-numbers_uketd4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdecluttersolutions%2Fimage%2Fupload%2Fv1621449371%2Ftalkjs%2Fcontact-info%2Fallowed-phone-numbers_uketd4.jpg" alt="Allowed phone numbers"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Advanced settings
&lt;/h4&gt;

&lt;p&gt;If the previous options do not cover your needs, we also implemented advanced settings to for allowed or forbidden matches using &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions" rel="noopener noreferrer"&gt;JavaScript regexp literal&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Allowed matches&lt;/code&gt; allow you to define patterns that might be suppressed based on the rules defined above. &lt;/p&gt;

&lt;p&gt;With the &lt;code&gt;Forbidden matches&lt;/code&gt; you extend the list of patterns that won't show in chat:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;certain words: &lt;code&gt;/banana|apple|pear|cherry/i&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;US ZIP Codes (both the five-digit and nine-digit): &lt;code&gt;/^[0-9]{5}(?:-[0-9]{4})?$/&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the user's message contains forbidden information, the section will be replaced by the &lt;code&gt;(Contact information was hidden)&lt;/code&gt; text:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdecluttersolutions%2Fimage%2Fupload%2Fv1621449371%2Ftalkjs%2Fcontact-info%2Fsuppressed-email_lmsjsw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fres.cloudinary.com%2Fdecluttersolutions%2Fimage%2Fupload%2Fv1621449371%2Ftalkjs%2Fcontact-info%2Fsuppressed-email_lmsjsw.jpg" alt="Suppressed email"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Final thoughts
&lt;/h3&gt;

&lt;p&gt;Contact suppression and word filtering are just some of the ways you can keep your users  safe and enforce your platform's guidelines. Check out our &lt;a href="https://talkjs.com/docs/Features/Security_Settings/Security_Recommendations.html" rel="noopener noreferrer"&gt;security recommendations&lt;/a&gt; for suggestions on how to further improve your customers' security and privacy.&lt;/p&gt;

&lt;p&gt;For any other questions, feel free to get in touch via the support chat on our &lt;a href="https://talkjs.com/" rel="noopener noreferrer"&gt;website&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>chat</category>
      <category>moderation</category>
      <category>community</category>
      <category>talkjs</category>
    </item>
  </channel>
</rss>
