<?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>Forem: vijay</title>
    <description>The latest articles on Forem by vijay (@vijayr).</description>
    <link>https://forem.com/vijayr</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%2F14957%2Fee8b2e3b-9c29-42c5-a8ff-b197bfd0f0a8.jpg</url>
      <title>Forem: vijay</title>
      <link>https://forem.com/vijayr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/vijayr"/>
    <language>en</language>
    <item>
      <title>Simple Twilio Forwarding</title>
      <dc:creator>vijay</dc:creator>
      <pubDate>Fri, 09 Oct 2020 23:53:44 +0000</pubDate>
      <link>https://forem.com/vijayr/simple-twilio-forwarding-4f4a</link>
      <guid>https://forem.com/vijayr/simple-twilio-forwarding-4f4a</guid>
      <description>&lt;p&gt;I was setting up an online store for a bunch of friends through Shopify. We setup chat channels using Messenger and Shopify Ping, but we still wanted to have a phone number in case the customers wanted to talk. The online store did not have a physical store and did not yet want to invest in a help desk setup.&lt;/p&gt;

&lt;p&gt;We came up with a simple solution through a Twilio phone number - that when called simultaneously rang the mobile phones of the partners.&lt;/p&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;A Phone Number&lt;/li&gt;
&lt;li&gt;Initial Greeting&lt;/li&gt;
&lt;li&gt;Simultaneous Dialings&lt;/li&gt;
&lt;li&gt;Record A Message&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  A Phone Number
&lt;/h2&gt;

&lt;p&gt;Twilio has been super great being a developer friendly service. We chose Twilio to purchase a virtual phone number. Some of the choices include region specific phone number or a toll free number. You can purchase once you sign up for free at &lt;a href="https://www.twilio.com"&gt;twilio.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Purchase a number &lt;a href="https://www.twilio.com/console/phone-numbers/search"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jaxYjsm0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wdfilm2ypx4kxzzo9g1v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jaxYjsm0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wdfilm2ypx4kxzzo9g1v.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search for a number of your liking&lt;/li&gt;
&lt;li&gt;Choose Voice capability&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Initial Greeting
&lt;/h2&gt;

&lt;p&gt;When any customer calls the above phone number, you could program it in multiple ways. We went with creating a simple TwiML script.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Configure your active numbers &lt;a href="https://www.twilio.com/console/phone-numbers/incoming"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Configure the Voice &amp;amp; Fax section by choosing &lt;em&gt;TwiML Bin&lt;/em&gt; for &lt;em&gt;A call comes&lt;/em&gt; in option &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K72dEF33--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nb1djhsncpivfmv0mpgz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K72dEF33--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/nb1djhsncpivfmv0mpgz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Press the + on the right to create a new TwiML script (full script in the end)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Voice greeting can be set using the &lt;strong&gt;&lt;/strong&gt; block.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;Say voice="man"&amp;gt;
      Welcome to online store dot com - please wait while we connect your call.
    &amp;lt;/Say&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;&amp;lt;Say&amp;gt;&lt;/code&gt; block speaks the text in a computerized (yet human-like) voice. There are multiple options for &lt;code&gt;voice&lt;/code&gt; available.&lt;/p&gt;

&lt;h2&gt;
  
  
  Simultaneous Dialings
&lt;/h2&gt;

&lt;p&gt;The next requirement was to have the incoming call result in calling a few of the partners and the most available person would pick up and connect the call.&lt;/p&gt;

&lt;p&gt;This code block dials the numbers in the values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;Dial timeout="20" record="true" callerId="+19000000000"&amp;gt;
      &amp;lt;Number&amp;gt;+16000000000&amp;lt;/Number&amp;gt;
      &amp;lt;Number&amp;gt;+14000000000&amp;lt;/Number&amp;gt;
    &amp;lt;/Dial&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Parameters &lt;code&gt;timeout&lt;/code&gt;, &lt;code&gt;record&lt;/code&gt;, and &lt;code&gt;callerId&lt;/code&gt; are passed to the Dial block. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;timeout&lt;/code&gt; sets the number of seconds the numbers below should ring before going to the next block&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;record&lt;/code&gt; sets the setting to record or not&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;callerId&lt;/code&gt; sets the phone number from which the Numbers below should receive the calls. We set to a Twilio verified number, as we wanted to partners to know that this is a call for the online store. You will not be able to specify a number that has not been verified in Twilio&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;Number&amp;gt;...&amp;lt;/Number&amp;gt;&lt;/code&gt; blocks are put inside &lt;code&gt;&amp;lt;Dial&amp;gt;&lt;/code&gt; block to dial simultaneously.&lt;/p&gt;

&lt;h2&gt;
  
  
  Record A Message
&lt;/h2&gt;

&lt;p&gt;At instances where all the few partners are able to receive the call, we wanted the customer to record a message to replay and address the needs.&lt;/p&gt;

&lt;p&gt;This code block achieves the requirement&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;Say voice="man"&amp;gt;
      All our representatives are busy. Please leave a message and we will contact you back. Thank you.
    &amp;lt;/Say&amp;gt;
    &amp;lt;Record maxLength="20" /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Before recording the voicemail, we put a prompt that everyone is busy and to leave a message.&lt;/li&gt;
&lt;li&gt;Record block records upto 20 seconds of voice&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;TwiML script is executed top down one block at a time. &lt;code&gt;&amp;lt;response&amp;gt;&lt;/code&gt; block will be executed as response to the incoming call. Here is the full code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;Response&amp;gt;
    &amp;lt;Say voice="man"&amp;gt;
      Welcome to online store dot com - please wait while we connect your call.
    &amp;lt;/Say&amp;gt;
    &amp;lt;Dial timeout="20" record="true" callerId="+19000000000"&amp;gt;
      &amp;lt;Number&amp;gt;+16000000000&amp;lt;/Number&amp;gt;
      &amp;lt;Number&amp;gt;+14000000000&amp;lt;/Number&amp;gt;
    &amp;lt;/Dial&amp;gt;
    &amp;lt;Say voice="man"&amp;gt;
      All our representatives are busy. Please leave a message and we will contact you back. Thank you.
    &amp;lt;/Say&amp;gt;
    &amp;lt;Record maxLength="20" /&amp;gt;
&amp;lt;/Response&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Hope this helps you in a similar case. Please let me know if there is a better way to fulfil the requirements.&lt;/p&gt;

&lt;p&gt;Also, here is a &lt;a href="//www.twilio.com/referral/xlaXwS"&gt;referral link&lt;/a&gt; if you would like to try out Twilio.&lt;/p&gt;

</description>
      <category>twilio</category>
      <category>ecommerce</category>
      <category>startup</category>
      <category>voice</category>
    </item>
  </channel>
</rss>
