create account

Tutorial - Aprende a como enviar mensajes de texto (sms) via Twilio con Node.js usando codigo javascript moderno ES6 (Babel) / Learn how to send text messages (sms) via Twilio with Node.js using modern javascript code ES6 (Babel) by jfdesousa7

View this thread on: hive.blogpeakd.comecency.com
· @jfdesousa7 ·
$6.30
Tutorial - Aprende a como enviar mensajes de texto (sms) via Twilio con Node.js usando codigo javascript moderno ES6 (Babel) / Learn how to send text messages (sms) via Twilio with Node.js using modern javascript code ES6 (Babel)
<center>
<img src="https://tupaginaonline.net/images_blog/17_16_35blg.jpg" class="img-fluid" />
</center>

<table>
	<tr>
		<td>Hoy aprenderemos a enviar un sms y recibir una respuesta usando los servicios de Twilio a través de Node con su framework Express usando código moderno ES6 (Babel)</td>
		<td>Today we will learn to send an SMS and receive a response using Twilio services through Node with its Express framework using code Today we will learn to send an SMS and receive a response using Twilio services through Node with its Express framework using code modern ES6 (Babel)</td>
	</tr>
</table>


<p><a href="https://www.twilio.com/">Twilio</a> es una compañía que ofrece una plataforma de comunicaciones así como de servicios en la nube, ubicada en San Francisco, California. Twilio permite desarrollar aplicaciones que hagan y reciban llamadas, mensajes de texto, elaboren funciones de comunicación y registro, usando APIs, propias del servicio web.</p>


<blockquote>
<p><a href="https://www.twilio.com/">Twilio</a> is a company that offers a communications platform as well as cloud services, located in San Francisco, California. Twilio allows you to develop applications that make and receive calls, text messages, develop communication and registration functions, using APIs, typical of the web service.</p>
</blockquote>


<br/><br/>

<table>
	<tr>
		<td> Empezaremos instalando todos los modulos necesarios para nuestro ejemplo: </td>
		<td> We will start by installing all the necessary modules for our example: </td>
	</tr>
</table>

<div class="gatsby-highlight">
<pre class="gatsby-code">
<code class="gatsby-code"><b class="token function">npm</b> install express twilio @babel/node @babel/cli @babel/core @babel/preset-env
</code>
</pre>
</div>


<table>
	<tr>
		<td>Crearemos un archivo nuevo llamado <b>.babelRC </b>que contendrá lo siguiente:</td>
		<td>We will create a new file called <b>.babelRC</b> that will contain the following:</td>
	</tr>
</table>

<div class="gatsby-highlight">
<pre class="gatsby-code">
<code class="gatsby-code">{
	"presets":[
		"@babel/env"
	]
}</code>
</pre>
</div>


<table>
	<tr>
		<td>Ahora procedemos a navegar hasta <a target="_blank" href="https://www.twilio.com/">twilio.com</a> y crear nuestra cuenta para obtener nuestro número de teléfono y la cuenta SID y el Auth token necesario para este ejemplo</td>
		<td>Now we proceed to navigate to <a target="_blank" href="https://www.twilio.com/"> twilio.com </a> and create our account to obtain our phone number and SID account and the Auth token required for this example</td>
	</tr>
</table>

<div class="gatsby-highlight">
<center>
<img src="https://tupaginaonline.net/archivos/arc17_14_06.jpg" class="img-fluid" />
</center>
</div>
<br/>
<table>
	<tr>
		<td>En nuestra raíz del proyecto creamos un archivo llamado <b>.env</b> que contendrá dichas claves de autenticación, el contenido del archivo es este:</td>
		<td>In our project root we create a file called <b> .env </b> that will contain these authentication keys, the content of the file is this</td>
	</tr>
</table>


<div class="gatsby-highlight">
<center>
<img src="https://tupaginaonline.net/archivos/arc17_14_28.jpg" class="img-fluid" />
</center>
</div>
<br/>

<b>Index.js</b>

<table>
	<tr>
		<td>Procedemos a copiar el siguiente código </td>
		<td>We proceed to copy the following code</td>
	</tr>
</table>

<div class="gatsby-highlight">
<pre class="gatsby-code">
<code class="gatsby-code">import dotenv from 'dotenv'
dotenv.config()
const accound_sid = process.env.ACCOUND_SID
const auth_token = process.env.AUTH_TOKEN
const port = process.env.PORT || 4000
import client from 'twilio'
const MessagingResponse = client.twiml.MessagingResponse
import express from 'express'
const app = express()
app.use(express.json())
app.get('/', (req,res)=>{
    res.send('Welcome!!')
})
app.get('/send', async(req,res) => {
    try{
        const message =  await client(accound_sid,auth_token).messages.create({
                    body: 'Mensaje de prueba - sms from twilio',
                    from: '+xxxxxxxx',
                    to:'+xxxxxxx'
        })
        res.json(message.sid)
    }catch(err){
        console.log(err)
    }
})
app.post('/sms', (req,res) => {
    const twiml = new MessagingResponse();
    twiml.message('He recibido tu mensaje.');
    res.writeHead(200,{'Content-Type':'text/xml'});
    res.end(twiml.toString());
})
app.listen(port, () => {
    console.log('Server on port', port)
})
</code>
</pre>
</div>


<table>
	<tr>
		<td>Antes de ejecutar nuestro ejemplo modificaremos el package.json de la siguiente manera:</td>
		<td>Before running our example we will modify the package.json as follows:</td>
	</tr>
</table>
<b>package.json</b>
<div class="gatsby-highlight">
<pre class="gatsby-code">
<code class="gatsby-code">"scripts": {
		"start": "babel-node index.js"
  }</code>
</pre>
</div>

<table>
	<tr>
		<td>Ahora desde nuestra terminal procedemos a ejecutar el sguiente comando </td>
		<td>Now from our terminal we proceed to execute the following command</td>
	</tr>
</table>

<div class="gatsby-highlight">
<pre class="gatsby-code">
<code class="gatsby-code"><b class="token function">npm</b> start
</code>
</pre>
</div>

<table>
	<tr>
		<td>Vamos en nuestro navegador y colocamos http://localhost:4000/send</td>
		<td>We go in our browser and put http://localhost:4000/send</td>
	</tr>
</table>


<table>
	<tr>
		<td>Y con eso debería de llegar un sms a al numero indicado en el código arriba  <b>(to)</b> de parte de <b>(from)</b></td>
		<td>And with that a sms should arrive at the number indicated in the code above <b>(to)</b> from <b> (from)</b></td>
	</tr>
</table>


<table>
	<tr>
		<td>Para probar la respuesta automática (endpoint sms/) habría que subirla a un hosting (recomiendo <b>heroku</b> para ello)</b></td>
		<td>To test the automatic response (endpoint sms /) it would be necessary to upload it to a hosting (I recommend <b> heroku </b> for this)</td>
	</tr>
</table>

<p>Adjunto captura de mi teléfono  /  Attached capture of my phone</p>


<div class="gatsby-highlight">
<center>
<img src="https://tupaginaonline.net/archivos/arc17_18_38.jpg" class="img-fluid" />
</center>
</div>

<br/><br/><br/><br/><br/>
<p>Y con esa amigos  llegamos al final del tutorial, espero que lo hayan disfrutado y hasta la próxima! / And with that friend we come to the end of the tutorial, I hope you enjoyed it and until next time!</p><br/>


<p style="color:red">Visite mi sitio web oficial / Visit my official website</p>

<center><a href="https://tupaginaonline.net" target="_blank"><b>tupaginaonline.net</b></a></center>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorjfdesousa7
permlinktutorial-aprende-a-como-enviar-mensajes-de-texto-sms-via-twilio-con-node-js-usando-codigo-javascript-moderno-es6-babel-learn-how
categoryhive-148441
json_metadata{"tags":["ocd","cervantes","appreciator","dev","developspanish","spanish","originalcontent"],"image":["https://tupaginaonline.net/images_blog/17_16_35blg.jpg","https://tupaginaonline.net/archivos/arc17_14_06.jpg","https://tupaginaonline.net/archivos/arc17_14_28.jpg","https://tupaginaonline.net/archivos/arc17_18_38.jpg"],"links":["https://www.twilio.com/"],"app":"hiveblog/0.1","format":"markdown"}
created2021-01-31 21:23:27
last_update2021-01-31 21:23:27
depth0
children7
last_payout2021-02-07 21:23:27
cashout_time1969-12-31 23:59:59
total_payout_value3.188 HBD
curator_payout_value3.114 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length6,639
author_reputation19,305,981,226,487
root_title"Tutorial - Aprende a como enviar mensajes de texto (sms) via Twilio con Node.js usando codigo javascript moderno ES6 (Babel) / Learn how to send text messages (sms) via Twilio with Node.js using modern javascript code ES6 (Babel)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,646,469
net_rshares24,332,449,490,369
author_curate_reward""
vote details (39)
@developspanish ·
Excelente tutorial y bien explicado, ya hace mucho deje de trabajar con Twilio, pero es una gran herramienta, sobre todo cuando quieres hacer KYC y confirmar que un número telefónico es dueño.
properties (22)
authordevelopspanish
permlinkre-jfdesousa7-qntivc
categoryhive-148441
json_metadata{"tags":["hive-148441"],"app":"peakd/2021.01.3"}
created2021-01-31 21:40:27
last_update2021-01-31 21:40:27
depth1
children3
last_payout2021-02-07 21:40:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length192
author_reputation4,482,396,340,474
root_title"Tutorial - Aprende a como enviar mensajes de texto (sms) via Twilio con Node.js usando codigo javascript moderno ES6 (Babel) / Learn how to send text messages (sms) via Twilio with Node.js using modern javascript code ES6 (Babel)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,646,690
net_rshares0
@jfdesousa7 ·
Gracias, pronto subiré mas contenido, así voy puliendo los tutoriales acá en hive
👍  ,
properties (23)
authorjfdesousa7
permlinkqntj7i
categoryhive-148441
json_metadata{"app":"hiveblog/0.1"}
created2021-01-31 21:47:48
last_update2021-01-31 21:47:48
depth2
children2
last_payout2021-02-07 21:47:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length81
author_reputation19,305,981,226,487
root_title"Tutorial - Aprende a como enviar mensajes de texto (sms) via Twilio con Node.js usando codigo javascript moderno ES6 (Babel) / Learn how to send text messages (sms) via Twilio with Node.js using modern javascript code ES6 (Babel)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,646,781
net_rshares53,803,507,681
author_curate_reward""
vote details (2)
@developspanish ·
Genial, me encantara ver tu contenido dentro de la comunidad de [Develop Spanish](https://peakd.com/c/hive-154226) o desde el tag #developspanish, poco a poco tendremos mas desarroladores hablando de programación :D
properties (22)
authordevelopspanish
permlinkre-jfdesousa7-qntjve
categoryhive-148441
json_metadata{"tags":["hive-148441"],"app":"peakd/2021.01.3"}
created2021-01-31 22:02:03
last_update2021-01-31 22:02:03
depth3
children1
last_payout2021-02-07 22:02:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length215
author_reputation4,482,396,340,474
root_title"Tutorial - Aprende a como enviar mensajes de texto (sms) via Twilio con Node.js usando codigo javascript moderno ES6 (Babel) / Learn how to send text messages (sms) via Twilio with Node.js using modern javascript code ES6 (Babel)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,647,046
net_rshares0
@hivebuzz ·
Congratulations @jfdesousa7! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

<table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@jfdesousa7/upvoted.png?202101312222"></td><td>You received more than 800 upvotes. Your next target is to reach 900 upvotes.</td></tr>
</table>

<sub>_You can view your badges on [your board](https://hivebuzz.me/@jfdesousa7) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



**Check out the last post from @hivebuzz:**
<table><tr><td><a href="/hivebuzz/@hivebuzz/pud-202102"><img src="https://images.hive.blog/64x128/https://i.imgur.com/805FIIt.jpg"></a></td><td><a href="/hivebuzz/@hivebuzz/pud-202102">Next Hive Power Up Day is February 1st 2021</a></td></tr></table>
properties (22)
authorhivebuzz
permlinkhivebuzz-notify-jfdesousa7-20210131t223029000z
categoryhive-148441
json_metadata{"image":["http://hivebuzz.me/notify.t6.png"]}
created2021-01-31 22:30:27
last_update2021-01-31 22:30:27
depth1
children0
last_payout2021-02-07 22:30:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length926
author_reputation369,432,312,084,136
root_title"Tutorial - Aprende a como enviar mensajes de texto (sms) via Twilio con Node.js usando codigo javascript moderno ES6 (Babel) / Learn how to send text messages (sms) via Twilio with Node.js using modern javascript code ES6 (Babel)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,647,685
net_rshares0
@neuerko ·
@tipu curate 
properties (22)
authorneuerko
permlinkre-jfdesousa7-2021131t15286766z
categoryhive-148441
json_metadata{"tags":["ocd","cervantes","appreciator","dev","developspanish","spanish","originalcontent"],"app":"ecency/3.0.13-mobile","format":"markdown+html"}
created2021-01-31 21:28:06
last_update2021-01-31 21:28:06
depth1
children1
last_payout2021-02-07 21:28:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length13
author_reputation189,659,636,099,356
root_title"Tutorial - Aprende a como enviar mensajes de texto (sms) via Twilio con Node.js usando codigo javascript moderno ES6 (Babel) / Learn how to send text messages (sms) via Twilio with Node.js using modern javascript code ES6 (Babel)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,646,533
net_rshares0
@tipu ·
<a href="https://tipu.online/hive_curator?neuerko" target="_blank">Upvoted  &#128076;</a> (Mana: 98/112) <a href="https://peakd.com/hive/@reward.app/reward-app-quick-guide-updated" target="_blank">Liquid rewards</a>.
properties (22)
authortipu
permlinkre-re-jfdesousa7-2021131t15286766z-20210131t212813z
categoryhive-148441
json_metadata"{"app": "beem/0.24.20"}"
created2021-01-31 21:28:15
last_update2021-01-31 21:28:15
depth2
children0
last_payout2021-02-07 21:28:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length216
author_reputation55,938,768,526,111
root_title"Tutorial - Aprende a como enviar mensajes de texto (sms) via Twilio con Node.js usando codigo javascript moderno ES6 (Babel) / Learn how to send text messages (sms) via Twilio with Node.js using modern javascript code ES6 (Babel)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id101,646,535
net_rshares0