<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Léon Rodenburg on Medium]]></title>
        <description><![CDATA[Stories by Léon Rodenburg on Medium]]></description>
        <link>https://medium.com/@leonrodenburg?source=rss-46dcbcbefdbb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5YF2iJ_4wc03eNCllixXQg.jpeg</url>
            <title>Stories by Léon Rodenburg on Medium</title>
            <link>https://medium.com/@leonrodenburg?source=rss-46dcbcbefdbb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 31 May 2026 18:48:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@leonrodenburg/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Automatic database sharding with Alibaba Cloud Table Store]]></title>
            <link>https://medium.com/xebia/automatic-database-sharding-with-alibaba-cloud-table-store-730fa25e2467?source=rss-46dcbcbefdbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/730fa25e2467</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[alibabacloud]]></category>
            <category><![CDATA[cloud-patterns]]></category>
            <category><![CDATA[cloud-architecture]]></category>
            <category><![CDATA[database-sharding-pattern]]></category>
            <dc:creator><![CDATA[Léon Rodenburg]]></dc:creator>
            <pubDate>Mon, 06 May 2019 16:42:19 GMT</pubDate>
            <atom:updated>2019-05-06T16:42:19.775Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7aJPlxn8gwhI7JjcBFr-tQ.jpeg" /></figure><p>At some point in your application’s lifecycle, there might come a time when you need to start scaling your data storage. If you are storing media files or other blobs that have no relations between them, you can easily add storage capacity to solve the problem. For (semi-)structured data in a database however, scaling is a whole different story. Simply adding database instances is not enough. You will need to reconsider the usage patterns and decide what solution solves the problem you have. If your database is hitting resource limits because it is accessed very frequently, adding an asynchronous read replica might be the way to go. If the size of the data is the issue and lookups become very slow, you might consider sharding your database.</p><p>In this post, we will look at how Table Store can help us shard our data automatically. <a href="https://www.alibabacloud.com/product/table-store">Table Store</a> is a NoSQL database service in Alibaba Cloud. It is available in all <a href="https://www.alibabacloud.com/global-locations">regions of Alibaba Cloud</a>. Because of its architecture, Table Store can store an unlimited amount of data and still keep read/write throughput at a very high level. It also offers secondary indices, search options and data streaming capabilities. For now, we will focus on basic operations to learn how data is stored.</p><h3>Sharding in a nutshell</h3><p>When your data size is becoming too large to efficiently query, you will often end up sharding your data. A shard is a partition of a full table that contains only a subset of the records. If you have two shards for a single table, each shard will contain half of the rows. Every record gets assigned to a shard when it is created. The target shard is determined by a hash of the primary key of the record. When the record needs to be retrieved from the table, the same hash is calculated. You then only have to traverse the target shard where the record lives and can skip all other shards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x488oKVrrB7H3d1NB37VvQ.jpeg" /><figcaption>Database sharding analogy: every drawer contains a subset of the data</figcaption></figure><p>A real-life analogy would be a closet of small drawers with patient information in it. When you need to store a patient’s information, you determine which drawer (or shard) the information card goes. Your sharding strategy is likely based on the first letter of the last name. Then you look up the drawer that contains cards with that letter and put it in. When someone requests a patient’s information, you look up the drawer again for his or her last name. Then you flick all cards and find the correct one.</p><h3>Choosing the right sharding strategy</h3><p>As you might see now, database sharding is very similar. The only real difference is the sharding strategy. In the real world, you would shard the data by the first letter of the last name. In a database however, you calculate a hash from one of the fields in the data and let the computer decide which shard it should fall in. The field that you use to shard the data is often called the partition key (or sometimes hash key). It is part of the primary key of a record.</p><p>But what do you do if your colleague John has the bad habit of putting the cards into a drawer randomly? You might have to flick all of the cards in a certain drawer to find the correct one. It might be smart to ask your colleague to sort the cards in the drawer. That will help you look up the right one even faster. A good choice would be to sort the cards by last name. You can split the stack of cards in half, see if the card you picked is lower or higher in alphabetical order than the card you need, split the remaining stack again and keep going until you find the right one. This is a <a href="https://en.wikipedia.org/wiki/Binary_search_algorithm">binary search algorithm</a> and makes it really efficient to look up a single value. This method only works because the cards are sorted, so you will have to make sure John adheres to the strategy.</p><p>In a digital database, the values in a single shard are also stored in a certain order. As long as the records are sorted, the computer can perform binary search. You have to decide on the sort order yourself, because the database can not decide what usage patterns you have. To make a decision you need to consider the usage patterns of your application. For key-value access patterns, where you always want to read a single value with a known primary key, you will probably sort by the partition key that was also used for sharding. If you need more complex queries, like range queries or filtering, you should add the fields that support those queries to the primary key. For example, if you need to query records by a date range, it would be most efficient to have the records sorted by that date. A final note is that every record should be uniquely identifiable in the end, which means that the combination of fields for the primary key have to be unique.</p><h3>Looking at Table Store</h3><p>Let’s see how Table Store helps us solve the intricacies of database sharding described above. I assume you have created an account and are logged in to the <a href="https://home-intl.console.aliyun.com">Alibaba Cloud Management Console</a>. Open the ‘Products’ drawer and selected ‘Table Store’. Switch to the region closest to you before proceeding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BOojZGnduOwH8UYjQPf_sw.png" /><figcaption>Alibaba Cloud and Table Store logos</figcaption></figure><p>Before we can start creating sharded tables, we need to create a Table Store instance. An instance is a container around one or more tables. It is similar to a database in traditional database systems. Click the blue ‘Create Instance’ button in the top-right corner to create an instance. Fill in a name, choose a type (Capacity or High-performance) and fill in a description. The difference between the two types is not important here, but if you want you can read more about it <a href="https://www.alibabacloud.com/help/doc-detail/52664.htm">here</a>. Click ‘OK’ to create the instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hLlCay25IIMOfVHVpBFWng.png" /><figcaption>Creating a Table Store instance</figcaption></figure><p>When the instance is created, click on its name to go to the detail page. You will see some access URLs and a list of tables. To start creating your first table, click ‘Create Table’ in the top-right corner.</p><p>First you should decide on a name for the table. If you want to store user profiles, Profiles might be a good pick. Leave the advanced settings disabled for now and start building up the primary key. As you can see, the first field in the primary key will become the partition key. You might recall that this is the data point that is hashed to determine which partition the record is put in. If you want to store user profiles, the userId might be a good choice. That will allow us to access the user profiles as a key-value store. Fill in userId in the field and selected String as the data type. Using a <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUID</a> for user profiles is often a good idea, so that will be a string. Click ‘OK’ to create the table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9XVgbEEY5AinxIY3JNp0Mw.png" /><figcaption>Creating a table</figcaption></figure><p>That is it. We’ve created a sharded table in Table Store that can contain an extreme amount of data. We don’t have to worry about scaling compute resources, database instances or read replicas. All of that is handled behind the scenes so we can focus on building our application.</p><p>To insert some data, click on the table name after you’ve created the table. Then click ‘Data Editor’ in the left pane. A newly created table is empty of course, so let’s input some data. Click the blue ‘Insert’ button to insert a record. We are asked to fill in the primary key fields, which for us is only userId , so <a href="https://www.uuidgenerator.net/">generate a UUID here</a>. Copy the UUID and put it in the userId column. Because Table Store is a NoSQL database, you can store any other fields you want in a record without specifying a schema. Records in a NoSQL database are sometimes also referred to as documents.</p><p>For our user profiles, we want to store the user’s first name, last name and age. To add the fields, click the ‘Add Column’ button. Fill in firstName, choose the String type and fill in your first name. Do the same for the lastName and age fields. Make sure the agefield is of type Integer. If everything looks like the image below, click ‘Insert’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S4oowEgiwYqokDgRdW7drw.png" /><figcaption>Inserting a record through the management console</figcaption></figure><p>You’ve just created your first record in a Table Store table! After the record is inserted, you will go back to the data editor to see what is in the table. Try to insert another record with the same fields. Or remove one of the records. You can also try adding a record with different fields to see what happens. Then delete that record again. The data editor will always reflect the records as a table, with rows and columns, but it is important to remember that you are working with a NoSQL database. That means that there is no overarching schema for all the records in a table, only the primary key is defined up front.</p><h3>Managing data programmatically</h3><p>In your application, it is clearly not feasible to manage all the data by hand with the data editor. Luckily, Table Store has <a href="https://www.alibabacloud.com/help/doc-detail/86528.htm">SDKs for several languages</a> so you can access your data in code. Among the supported languages is Python. I will show you how you can create and update records in Python easily using the SDK. I have set up <a href="https://github.com/leonrodenburg/ali-ots-example">a repository</a> with a simple Flask application that should make it easy to get started.</p><p>To get started in your Python project, you need to install the SDK:</p><pre>pip install tablestore</pre><p>Then, you can instantiate the OTSClient that allows you to interface with all the Table Store APIs:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/55100f49fb4b44c5b2cef1d26c581841/href">https://medium.com/media/55100f49fb4b44c5b2cef1d26c581841/href</a></iframe><p>You have to import the `OTSClient` from the tablestore package. Then you can instantiate it with an endpoint, access key ID, access key secret and the instance name. The endpoint and instance name can be found in the Table Store dashboard of the instance you created. Make sure to use the internet endpoint if you want to talk to Table Store from your local machine. An access key can be created on the <a href="https://usercenter.console.aliyun.com/#/manage/ak">Security Management dashboard</a>. It is used to programmatically access the resources in your Alibaba Cloud account.</p><p>In the example above, the Table Store information and credentials are loaded from the environment. You can replace it with the actual values or make sure to set them before running the application.</p><p>Now let’s create an endpoint for fetching a profile:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6e2605577db2b6acae7ad08f2e06eac/href">https://medium.com/media/c6e2605577db2b6acae7ad08f2e06eac/href</a></iframe><p>In the /profile/&lt;user_id&gt;route, we define the user_id as a primary key field and call client.get_row() to fetch a row from the Profile table. As we would like to return JSON from our Flask endpoint, we need to interpret the resulting row and transform it in to a Python dictionary. To do this, we add all primary keys and attribute columns (like firstName , lastName and age ) into the dictionary. That dictionary is then transformed into JSON and returned from the API.</p><p>The process of storing a record in the table is very similar:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/320c24cb1544d32f8806c68b4e270ce6/href">https://medium.com/media/320c24cb1544d32f8806c68b4e270ce6/href</a></iframe><p>Here we create a POST endpoint with the same URL as the endpoint used to fetch records. A Row object is then created from the primary key and the attribute columns. The primary key is just the user_id , while a list comprehension is used to get all other columns as a list of tuples. That is then set as the attribute columns for the Row . Finally, we call client.put_row() to store the record. Note that this is an idempotent store operation. If a record already exists with the same ID, the current contents are overwritten.</p><p>Table Store has many more options like versioning of records and fields, secondary indices that help you look up data with different access patterns and a full-fledged search index to search all the data. If you want to learn more about those, please refer to <a href="https://www.alibabacloud.com/help/product/27278.htm">the documentation</a>.</p><h3>Wrapping it up</h3><p>We have seen how the basics of database sharding work, how Table Store enables us to easily shard data and how you can use the Table Store SDKs to access your data programmatically. The <a href="https://github.com/leonrodenburg/ali-ots-example">code repository</a> contains a working example of the Flask app that you can boot locally as follows.</p><ul><li>Clone the repository</li><li>Create a .env file in the cloned directory with the following contents:</li></ul><pre>OTS_ENDPOINT=endpoint<br>OTS_INSTANCE=instance-name<br>ACCESS_KEY_ID=access-key<br>ACCESS_KEY_SECRET=access-key-secret</pre><p>Replace the values with the Table Store endpoint, instance name and access key information relevant to you.</p><ul><li>Use <a href="https://github.com/pypa/pipenv">Pipenv</a> to create a virtual environment and install the dependencies:</li></ul><pre>pipenv install</pre><ul><li>Run the application:</li></ul><pre>FLASK_DEBUG=1 FLASK_APP=src/app.py pipenv run flask run</pre><p>This uses the Pipenv virtual environment to start up the Flask app. It will expose the /profile/&lt;user_id&gt; GET and POST endpoints to fetch and store data. Make sure your Table Store instance contains a Profile table with the corresponding primary key (a single userId field that is a String ).</p><p>Lastly, if you are familiar with <a href="https://www.terraform.io/">Terraform</a>, you can use the Terraform template in the repository to provision a Table Store instance and table. It also specifies the key structure of the table so you should be good to go after the template is deployed.</p><p>Happy sharding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=730fa25e2467" width="1" height="1" alt=""><hr><p><a href="https://medium.com/xebia/automatic-database-sharding-with-alibaba-cloud-table-store-730fa25e2467">Automatic database sharding with Alibaba Cloud Table Store</a> was originally published in <a href="https://medium.com/xebia">Xebia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Auto-Scaling on Alibaba Cloud]]></title>
            <link>https://medium.com/xebia/auto-scaling-on-alibaba-cloud-99d1d9ac1c6b?source=rss-46dcbcbefdbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/99d1d9ac1c6b</guid>
            <category><![CDATA[alibabacloud]]></category>
            <category><![CDATA[cloud-architecture]]></category>
            <category><![CDATA[cloud-patterns]]></category>
            <category><![CDATA[auto-scaling-pattern]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Léon Rodenburg]]></dc:creator>
            <pubDate>Mon, 01 Apr 2019 14:29:31 GMT</pubDate>
            <atom:updated>2019-04-02T08:57:18.357Z</atom:updated>
            <content:encoded><![CDATA[<p>When you deploy your application on compute instances on-premise or in the cloud, you have to make an educated guess about the utilisation of the resources you provision. If you have an older version of the same application running with proper monitoring, you can base your guesstimate on the current usage of compute nodes. But when this is the first time your application goes to production you are out of luck. How many users will you have each day? What will users do when they start your application and how are usage peaks distributed? Do you expect growth in the number of users? How about long term? If you have answers to all of these questions, you might be well-equipped to go with your gut-feeling and just deploy the application on the number of nodes you came up with. Let’s assume you don’t have all the answers though (which is probably the case). This is where auto-scaling comes in.</p><p>In this article, I will introduce you to the concepts of auto-scaling and how it can help you deploy highly available applications on your cloud infrastructure. We will also look at Alibaba Cloud and see how auto-scaling is done there. By means of an experiment with Terraform, used to practise infrastructure as code, we will get acquainted with the moving parts in a typical auto-scaling setup.</p><h3>What is auto-scaling?</h3><p>Auto-scaling an application means that the nodes that are used to run that application can adapt to changes in load automatically. You can do <em>horizontal scaling</em> by adding new nodes with stateless copies of the application as needed. In most settings you could also scale vertically if you wanted to. <em>Vertical scaling</em> is the process of upgrading a single node with more CPU, memory or disk space. As vertical scaling is not common and often not the right solution to the problem, we will focus the discussion on scaling horizontally. Adding more identical nodes to your cluster is also referred to as <em>scaling out</em>, while removing nodes is called <em>scaling in</em>. Oftentimes the scaled nodes are grouped behind a load balancer, that will make sure all nodes receive an evenly distributed amount of traffic. As load balancing is a whole new topic in itself, I will not focus on load-balancing an application in this post.</p><p>The statelessness of the copies of the application on every node is very important. If a node stores state, for example user sessions in web applications, the state is lost when the node goes down or is removed from the auto-scaling group. This could mean that users are suddenly logged out of the application. The same goes for user-uploaded data or any other data that needs to be shared between the nodes. Normally you would use a database for user and session data or store files in network attached storage that is shared between nodes.</p><p>So what options are there for automating the scaling operations of your cluster? Most cloud providers have two choices: <em>scheduled</em> or <em>demand-based</em>. Scheduled scaling is done based on a daily, weekly or monthly schedule that defines when to scale out and when to scale in. This is applicable when you know that most users work with your application at a certain time of day. You could also use it to make sure you have enough capacity right before a new marketing campaign is launched. Demand-based scaling looks at metrics provided by the operating system of running nodes and makes decisions based on that. You could scale out when the average CPU usage is above a certain threshold, and scale in again when the CPU usage is low enough. Often you can also define custom metrics to base the scaling activity on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eq83tdydPpLKleSiF6F20A.png" /><figcaption>Simple scaling group in a VPC, without load balancing</figcaption></figure><p>Before we dive into setting up auto-scaling on Alibaba Cloud, it is important to understand what benefits auto-scaling might give you. Apart from providing the right user experience at the right time by scaling out when demand increases, scaling in appropriately can save you a lot of money on the monthly cloud bill. Although this kind of cost-optimisation is probably not the thing to start with for your new project, it can become very important as applications evolve. In any case, thinking about how to scale your application upfront can really prevent headaches when the time to cut costs arises.</p><h3>Alibaba Cloud</h3><p>As one of the lesser used cloud providers in Europe and the US, the Chinese Alibaba Cloud might not be your first choice for deploying a new project. But despite its relative anonymity, its feature set is pretty complete and has included all tools necessary to do auto-scaling since 2015. These tools are gathered under the name <em>Auto Scaling </em>in the services overview. With data centers in London, Frankfurt, Virginia and Silicon Valley amongst others, there should always be a region close enough to you so you can test the waters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*plI2C_zWauRPPIzohkZD0g.png" /></figure><h3>Implementing auto-scaling with Terraform</h3><p>To follow along with the implementation of Auto Scaling in Alibaba Cloud, you will need to register an account <a href="https://account.alibabacloud.com/register/intl_register.htm">here</a>. We will be practicing Infrastructure as Code using Terraform, so you should make sure that you have Terraform installed on your machine. Terraform helps us describe the resources we need in the cloud declaratively in configuration files. It can then apply any needed changes for you, so you don’t have to click through the management console yourself to update your resources. This gives you the valuable ability to plan resources, repeat deployments and destroy complete environments with simple command-line calls. Alibaba Cloud has an <a href="https://www.terraform.io/docs/providers/alicloud/index.html">official open-source Terraform provider</a> that makes it easy to create these repeatable deployments of resources in your Alibaba account. Auto Scaling is also among the supported services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*xxr8oyYUrA_DKqqOe2DhSw.png" /></figure><p>The full source code is contained in a <a href="https://github.com/leonrodenburg/ali-tf-examples/tree/master/3-auto-scaling">directory in this repository</a>. I will walk you through the most important parts of the templates and the deployment so you should have a running auto-scaling experiment in just a few minutes.</p><h3>Setting up the experiment</h3><p>To start the experiment, we need to clone the repository, move into the relevant directory and initialize Terraform so the plugins are installed:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bceb95c87ecdaef47617bad9edfc17d1/href">https://medium.com/media/bceb95c87ecdaef47617bad9edfc17d1/href</a></iframe><p>You should see a message like Terraform has been successfully initialized! that confirms that everything works.</p><p>If you look in the directory, you will see a bunch of .tf files and one user data file:</p><pre>.<br>├── _alicloud.tf<br>├── _variables.tf<br>├── template.tf<br>├── user-data.conf<br>└── vpc.tf</pre><pre>0 directories, 5 files</pre><p>The moving parts involved in auto-scaling are all in the template.tf file. We will focus our discussion on that file.</p><h3>Scaling group &amp; scaling configuration</h3><p>The template.tf file contains the following Terraform resources at the top:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/acf2ccbdc5e22e7bb9fa5c96c7bd8972/href">https://medium.com/media/acf2ccbdc5e22e7bb9fa5c96c7bd8972/href</a></iframe><p>A <em>scaling group</em> is the wrapper around all auto-scaling resources. It defines a minimum and maximum number of Elastic Compute Service (ECS) instances that should be in the group. If also defines which instances should be removed first in the removal policy. We also reference two VSwitches where our instances will be placed. A <em>VSwitch</em> is a virtual switch in an Alibaba Cloud VPC that defines a single subnet. We want to be highly available so we created two VSwitches (subnets), each in a separate availability zone. If you point to these in the scaling group then auto-scaling will make sure that instances are balanced across the specified VSwitches. The VPC and VSwitches are defined in vpc.tf , should you be curious about their definition. Also note the cooldown property, which defines how long auto-scaling should wait before triggering the next auto-scaling event. This makes sure that the scaling group will not go crazy on a short spike of traffic but the scaling is spread out more evenly.</p><p>The <em>scaling configuration</em> defined below the scaling group defines the template that is used to launch new instances. If you look closely, you can see that we reference the Ubuntu 18.04 image, so our instances will run that Linux distribution. The instance type is a small t5.nano to make sure our bill stays low for this experiment. Most other properties speak for themselves. Another important part is the user_data property, that points to a configuration file that is run on the machine during its boot process. If you look in the file user-data.conf you can see we install NGINX, fire it up and then start a stress test on the machine to generate some load:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/077e94eb8035c011ea710379d4782d2f/href">https://medium.com/media/077e94eb8035c011ea710379d4782d2f/href</a></iframe><p>The CPU load eats up a whole core for ten minutes, which will come in handy for the rest of the experiment.</p><h3>Scaling rules &amp; alarms</h3><p>We have now defined a scaling group and a scaling configuration, but have not defined how to scale our instances. Those definitions are called <em>scaling rules</em> and you can see two of them in template.tf :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e949cbaf51cdc9b963dd06eb9598f7a/href">https://medium.com/media/3e949cbaf51cdc9b963dd06eb9598f7a/href</a></iframe><p>The definition is straightforward. We create a rule called add-instance and another one remove-instance . These add and remove one instance respectively.</p><p>In itself, a scaling rule does nothing. It only gives a name to a certain type of scaling activity with a set amount. To actually perform the scaling, a scaling rule has to be triggered. We spoke earlier of the way auto-scaling can be performed in most public clouds, and this is where Alibaba Cloud is no different. You can trigger a scaling rule manually, on a schedule or after a customisable alarm goes off. We will choose the last option for this experiment:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/515dba8a01526e7c3de73c52d543236c/href">https://medium.com/media/515dba8a01526e7c3de73c52d543236c/href</a></iframe><p>In the last part of our resource definitions, we define the <em>alarms</em> that will trigger our scaling rules. We have one alarm that adds instances when the average CPU usage of our instances goes above 70% in a 60-second period and that value is found two times in a row. Every metric is evaluated every minute, so if we have two consecutive minutes of 70%+ average CPU usage the alarm will trigger. It will then add an instance (see the alarm_actions property).</p><p>As you might recall from the scaling configuration user data, we stress the single-core CPU for a full 10 minutes after it booted. The scaling group starts with 1 instance and goes up to a maximum of 3. So, when we start the experiment, a single instance will be booted. But after two minutes, a second instance will be started as the average CPU is above 70%. Then, again after two minutes, the third will be launched. A scaling group never goes above its maximum number of instances, so the experiment is capped at 3 instances.</p><p>After some time, the stress on the CPU will stop. Our average will drop again. If you look in the second alarm defined above, you can see that we will start removing instances as soon as the average CPU usage will go below 10% two times in a row. So, the alarm will trigger and start removing the oldest instance. After some time, it will also remove the second instance and leave us with the instance that was started up last. The scaling group will also never go below its minimum number of instances, so we will keep running a single instance. This concludes the experiment.</p><h3>Run the experiment</h3><p>Now that we have an expectation of what will happen with our resources, let’s start the experiment:</p><pre>export ALICLOUD_ACCESS_KEY<strong>=</strong>&quot;YOUR_ACCESS_KEY&quot;<br>export ALICLOUD_SECRET_KEY<strong>=</strong>&quot;YOUR_SECRET_KEY&quot;<br>export ALICLOUD_REGION<strong>=</strong>&quot;eu-central-1&quot;</pre><pre>terraform apply</pre><p>First we set environment variables with the access key, secret access key and region. The keys can be found in your account. I’ve set the region to eu-central-1 which is Frankfurt. Then use terraform apply to create an execution plan for the changes. Type yes to approve the changes and create the resources in your account.</p><p>You can go to the ECS and Auto-Scaling consoles to see the running experiment. It will take a few minutes before the first instance is booted and the second instance will be added. There are several buttons to see the monitoring for the scaling group, the instances and the alarms we set up. There’s also a Terraform query in place to get the running instances in the scaling group:</p><pre>terraform refresh -target=&quot;data.alicloud_instances.scaled-instances&quot;</pre><p>This will output the currently running ECS instances in our scaling group. If you look up the public IP addresses of the instances in the output and browse to them, you should see the default NGINX landing page.</p><h3>Conclusion</h3><p>This concludes the auto-scaling experiment on Alibaba Cloud. You should now have a good idea of why we need auto-scaling for making sure our application is highly available and our costs are kept to a minimum. You’ve also created a scaling group, scaling configuration, scaling rules and alarms in Alibaba Cloud using Terraform. The next step is to put the instances behind a load-balancer. This will create a single entry point for your application and distribute all the traffic among your instances. The <a href="https://www.terraform.io/docs/providers/alicloud/r/slb.html">documentation for Server Load Balancer (SLB) resources</a> should point you in the right direction!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99d1d9ac1c6b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/xebia/auto-scaling-on-alibaba-cloud-99d1d9ac1c6b">Auto-Scaling on Alibaba Cloud</a> was originally published in <a href="https://medium.com/xebia">Xebia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pub-Sub messaging with AWS SNS and SQS]]></title>
            <link>https://medium.com/xebia/pub-sub-messaging-with-aws-sns-and-sqs-4133ffaf6ef7?source=rss-46dcbcbefdbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/4133ffaf6ef7</guid>
            <category><![CDATA[pub-sub]]></category>
            <category><![CDATA[amazon]]></category>
            <category><![CDATA[sqs]]></category>
            <category><![CDATA[sns]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Léon Rodenburg]]></dc:creator>
            <pubDate>Thu, 07 Feb 2019 15:10:45 GMT</pubDate>
            <atom:updated>2019-02-07T15:10:45.586Z</atom:updated>
            <content:encoded><![CDATA[<p>When setting up a new application or platform, one of the most important things that you will need is messaging. As every part of the platform has a certain need for data, either realtime or after the fact, messages from other services within the application boundary need to be processed as efficiently as possible. This inter-executable messaging can go from simple notifications about something that happened in a domain (‘customer X changed his name to Y’) to a queue of outstanding jobs that are to be executed by workers. In any architectural case, be it (distributed) monolith, microliths, microservices or anything in between, messages will be there.</p><p>Pub-Sub (publish-subscribe) messaging is an asynchronous, decoupled style of messaging. The side where the message originates has no notion of any of the recipients, while the recipients do not know where the message came from. Pub-sub can help you to build a more resilient application, as you can change either the producing or subscribing side without any impact to the message flow. You could also scale both sides independently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/0*2HnPt0XN3LKnxEk5.png" /><figcaption>Pub-Sub messaging. Image from AWS website (<a href="https://aws.amazon.com/pub-sub-messaging/">https://aws.amazon.com/pub-sub-messaging/</a>)</figcaption></figure><h3>The AWS messaging candy shop</h3><p>As our platform is run on AWS, we’ve been trying to use more and more of the services you get (almost) for free out of the box. One of these is Kinesis, which served as an inter-service message bus where messages would be published and consumed by any interested party. Using Kinesis saved us from having to run and manage our own Kafka cluster and did not force us to choose a specific language or framework like some others do. We were on AWS anyway, so that buy-in had already been taken. After a while though, it showed that it lacked some of the properties that we needed for our applications. Most annoyingly, it is hard to debug or replay a single message. In Kinesis, you can replay messages by setting the tracker to a specific message ID. While this gets the job done, it also replays any of the messages that were sent after the one that you wanted to replay. Naturally, the application should be able to deduplicate any of the messages but sometimes it can be tough or costly to make it fully resilient to double delivery. So we looked for alternatives.</p><p>We had been using Amazon’s Simple Queue Service (SQS) for the last few weeks, to drive some of the more 1-to-1 asynchronous communication between several services. Unlike the streams of Kinesis or Kafka, where the messages are sharded, a queue is a simpler abstraction that can form a natural ‘inbox’ for a service. Especially for low priority messaging or processes where the user is not waiting for a response, the queue is at its best. Using SQS queues makes it possible to configure a dead letter queue, which is where the messages will end up if they could not be consumed for whatever reason. That is the hook you can use to debug and replay messages for only the consumers that failed. The down side of plain queues is that producers of messages need to know where to route them, so you lose a lot of the advantages of decoupling mentioned earlier.</p><p>In comes the AWS Simple Notification Service (SNS), our hero of the day. As the name suggests, it is used to send notifications. As the name does not suggest, at first glance, is that these notifications can also be messages on SQS queues. Do you see the pattern emerging? Decoupled messaging through SNS topics that are linked to the inboxes of the services that need those specific messages! Feels a bit like the best of both worlds.</p><h3>SNS + SQS = 🚀</h3><p>Alright, let’s try to set it up. I’ve created a repository (<a href="https://github.com/leonrodenburg/cfn-sns-sqs-messaging">available here</a>) with the CloudFormation templates to set up an SNS topic that is connected to one or more SQS queues that will also be created. That connection is called a subscription. To make the stack a bit more manageable and because CloudFormation does not support looping natively, I’ve used Sceptre’s Jinja2 templating in the `templates/sns-pubsub.j2` file. You don’t need to make any changes there. If you do not want to deploy in eu-west-1, you need to change `config/messaging/config.yaml` accordingly. Also, let’s have a look at `config/messaging/sns-pubsub.yaml`:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb74997d02e0593f6a334ecec35308ad/href">https://medium.com/media/eb74997d02e0593f6a334ecec35308ad/href</a></iframe><p>When you’re done editing, you can deploy the stack to AWS (this assumes you have Sceptre installed and valid credentials):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8258656f388122bbfcce77604579f26/href">https://medium.com/media/a8258656f388122bbfcce77604579f26/href</a></iframe><p>This will create the SNS topic and the SQS queues. It also sets up a queue policy so the SNS topic gets the rights to send messages to the queues. If you decide that you need more or less queues at a later point in time, you can just add them to or delete them from the array and use the same command to update the stack.</p><p>Let’s send a message on the SNS topic:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62d4654f9b29355f899a5637c0414853/href">https://medium.com/media/62d4654f9b29355f899a5637c0414853/href</a></iframe><p>Replace YOUR_ARN_HERE with the ARN of the created topic. You can find it in the SNS service in the AWS management console. This should return a simple JSON response with a message ID, if it succeeded.</p><p>If you now log in to the AWS management console and go to SQS, you should see the queues you created and that there is one message available in every queue. If you click a queue, you can select View/Delete Messages under Queue Actions. Click the blue Start Polling for Messages and your message should appear. My payload was as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/320bb6e65560616d091ed633826f5438/href">https://medium.com/media/320bb6e65560616d091ed633826f5438/href</a></iframe><p>Awesome! As a final side note, when you want to use this in real life, make sure that the producing side has the right roles or permissions to send notifications on the topic. Similarly, make sure the consuming side has the permissions to read from the queue.</p><p><em>Originally published at </em><a href="https://xebia.com/blog/pub-sub-messaging-with-aws-sns-and-sqs/"><em>xebia.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4133ffaf6ef7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/xebia/pub-sub-messaging-with-aws-sns-and-sqs-4133ffaf6ef7">Pub-Sub messaging with AWS SNS and SQS</a> was originally published in <a href="https://medium.com/xebia">Xebia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Speech Recognition and Synthesis in the Browser]]></title>
            <link>https://medium.com/xebia/speech-recognition-and-synthesis-in-the-browser-5f8a3df0f110?source=rss-46dcbcbefdbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f8a3df0f110</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[speech-recognition]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-speech-api]]></category>
            <category><![CDATA[speech-synthesis]]></category>
            <dc:creator><![CDATA[Léon Rodenburg]]></dc:creator>
            <pubDate>Fri, 15 Jun 2018 10:25:48 GMT</pubDate>
            <atom:updated>2018-06-15T11:48:41.676Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DG_E70S_DNwT_PSNkr0tkA.jpeg" /></figure><p>With the recent upsurge of Siri, Google Assistant and Amazon’s Alexa, speech recognition and synthesis have become an increasingly important tool in the developer’s toolbox. Working with speech data can not only improve the accessibility of your application. It can also increase conversion in your webshop, especially when customers shop on their mobile phones. Native apps have a large advantage in this space, as <a href="https://developer.apple.com/sirikit/">Apple’s SiriKit</a> and <a href="https://developers.google.com/assistant/sdk/">Google’s Assistant SDK</a> can get you up and running in a few minutes to hours.</p><p>For browsers, the story is different. If we disregard native apps for a second, plain old websites (or progressive web apps) seem to severely lag behind. How many websites can you mention from the top of your head that offer you the option to search with your voice? I can only think of a handful. Is it because people are scared to talk to their laptops, but are comfortable telling stories to their smartphones? Probably not. The biggest problem is that the easy solutions provided by libraries like SiriKit are not there for the web. Or are they?</p><p>To do speech recognition and synthesis you need a massive amount of training data for all kinds of languages in all kinds of settings. As a lone wolf or small startup, accruing that amount of data is near-impossible. So, you go to the companies that have already managed to train their neural networks: the Googles and Amazons. For a small amount of money per transcribed audio second, you can send your audio files to <a href="https://cloud.google.com/speech-to-text/">Google’s Cloud Speech-to-Text API</a> or <a href="https://aws.amazon.com/transcribe/">Amazon Transcribe</a>. They will transcribe the audio within sub-second response times. Although the technology is cool, setting it up can be a hassle, especially if you want to use the <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder">audio recorder provided in the browser</a>. The recording format of the browser does not always match the prescriptions of the cloud transcribers. This requires you to hit another backend for transcoding files into something that works. Yes I know, ugh.</p><p>When I recently had to implement a proof of concept voice search with some of my colleagues, we came across a 2012 (!) specification for speech recognition called the <a href="https://w3c.github.io/speech-api/webspeechapi.html">Web Speech API Specification</a>. In it we found several interfaces like SpeechRecognition and SpeechSynthesis which seemed to do exactly what we were looking for. Another round on Google brought us to the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API">following MDN page</a> on the Web Speech API. To our big surprise, the browser support table showed the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YPxIrp74nEyYLdej07jrZA.png" /><figcaption>Desktop support for Web Speech API</figcaption></figure><p>You don’t say! Chrome has had support since around 2013, when Chrome 25 was released. Coming to think of it, it is even weirder now that so little websites seem to make use of the native API’s that are supported in Chrome, Firefox and Edge. Disregarding the part of the user base that still uses Internet Explorer, we continued on our journey.</p><p>We based our implementation on a repository that accompanies the MDN page (<a href="https://github.com/mdn/web-speech-api">available here</a>). After downsizing it a little bit, our implementation looked something like the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c3737b9d8a2393b256149c71dce124b/href">https://medium.com/media/0c3737b9d8a2393b256149c71dce124b/href</a></iframe><p>And it worked! This piece of code will ask for your permission to use the microphone after 3 seconds. If you click ‘allow’, it will then listen how well you do on pronouncing Bahasa Indonesia. Finally, it logs the transcribed results in your console. If your Bahasa is rusty, you can of course change the language code on line 6 to any of the supported languages shown in <a href="https://www.google.com/intl/en/chrome/demos/speech.html">this demo</a>. Note that these are the languages available in Chrome, other browsers might have a different list.</p><p>The Web Speech API seems to do a pretty good job at transcribing user commands in various languages. By default, the recording will stop as soon as the user stops speaking. If you want to transcribe longer pieces of audio, you can also set recognition.continuous to true . In production environments, you would first want to check support for the SpeechRecognition interface and handle its absence. Also, it might be wise to only start recording after the user clicks a button instead of triggering it with a window.setTimeout() . But I’ll leave that as an exercise to you.</p><p>Speech recognition is a breeze to implement using the Web Speech API. Speech synthesis is even easier to implement, of which you can see the proof <a href="https://github.com/mdn/web-speech-api/blob/master/speak-easy-synthesis/script.js">here</a>. Enhancing your website with speech recognition can really enhance the user experience when it comes to searching or shopping. Inexperienced customers might like to express their intent in natural language, describing what they want to do or find. In traditional UIs, this is often not possible. Most search inputs force you to type in a condensed kind of language that does not even closely resemble a grammatically correct sentence or action, something which speech recognition might solve. Speech synthesis can in turn help in the realm of chatbots, notifications or messaging, amongst others. In short, smart assistant technologies can not only help us in our homes or on our phones, we can also use them anywhere on the web where natural language is a good transport for communication with your users. So, how are you going to use it in your app?</p><p><em>This blog post was originally published on the Xebia Blog, available </em><a href="http://blog.xebia.com/speech-recognition-and-synthesis-in-the-browser/"><em>here</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f8a3df0f110" width="1" height="1" alt=""><hr><p><a href="https://medium.com/xebia/speech-recognition-and-synthesis-in-the-browser-5f8a3df0f110">Speech Recognition and Synthesis in the Browser</a> was originally published in <a href="https://medium.com/xebia">Xebia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Your Business Should Be on the WeChat Platform (Part III): Implementing an echo service]]></title>
            <link>https://medium.com/xebia/no-wechat-no-life-part-3-implementing-an-echo-service-e625151268e6?source=rss-46dcbcbefdbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/e625151268e6</guid>
            <category><![CDATA[wechat]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[china]]></category>
            <dc:creator><![CDATA[Léon Rodenburg]]></dc:creator>
            <pubDate>Fri, 06 Apr 2018 09:40:46 GMT</pubDate>
            <atom:updated>2018-07-16T11:55:04.039Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this three-part series on WeChat, Léon will show you how ‘the Chinese alternative to WhatsApp’ is transforming the on- and offline lives of Chinese consumers, thereby forcing companies to reconsider their marketing and sales strategies. In the </em><a href="https://medium.com/xebia/why-your-business-should-be-on-the-wechat-platform-part-ii-wechat-feature-overview-7b7eae7427ac"><em>previous two parts</em></a><em>, he argued for the necessity of a presence on WeChat for companies facing Chinese customers and gave an overview of the features. In this part, he will show you how to build a simple echo service using the WeChat APIs.</em></p><p>After the previous two more theoretical posts, it is time to get our hands dirty. As you might recall from part 2 of this series, companies can register an official account (OA) on WeChat to get access to all the APIs that the platform provides. An OA shows up in a user’s chat list, either between the regular chats or in a dedicated folder, and can send and receive messages to users or provide other useful on-demand services in the chat. Today, we will build an endpoint that follows the WeChat standards and can be tested on WeChat using the debug sandbox. It will echo any message a user sends by replying with the contents of the message reversed. Although this is not a really compelling example, it sets you up with the right tools to build more enticing user experiences on WeChat (and it forces you to register a WeChat account ;)).</p><p>We will build the endpoint using Express, a library for creating web applications on Node.js, but it is important to understand that any type of HTTP server can be used. If you have an existing backend that needs to integrate with WeChat, you could of course implement it on the existing stack. As long as it fulfils the (simple) requirements set forth by WeChat, it will suffice. Let’s get started. The <a href="https://github.com/leonrodenburg/wechat-blog">final code</a> is on GitHub.</p><h4><strong>Step 1: Setup</strong></h4><ol><li>Make sure you have the latest (or a pretty recent) <a href="https://nodejs.org/en/download/">Node.js and NPM</a> installed on your machine.</li><li>Install <a href="https://ngrok.com/download">ngrok</a>. It will be used as a secure tunnel to your machine that WeChat can access, more on that later.</li><li>Create a new directory on your filesystem and initialize a new project (this guide assumes you are on a macOS machine, Linux or Windows users should change the commands and directories accordingly):</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8ae96482c4fa277733b37a56c26fc8b/href">https://medium.com/media/a8ae96482c4fa277733b37a56c26fc8b/href</a></iframe><p>Install Express through NPM:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/828bdbf7b22aeb65e93832e795cd8a1e/href">https://medium.com/media/828bdbf7b22aeb65e93832e795cd8a1e/href</a></iframe><p>Open the code editor of your choice and point it at the directory you just created (it should contain a package.json, package-lock.json and node_modules/ directory).</p><p><strong>Step 2: Get access to the WeChat sandbox</strong></p><ol><li>Install WeChat through the <a href="https://itunes.apple.com/nl/app/wechat/id414478124?mt=8">App Store</a> or <a href="https://play.google.com/store/apps/details?id=com.tencent.mm">Google Play</a> if you haven’t already and register an account. If you’re already on WeChat, you can skip this step.</li><li>Browse to the <a href="http://mp.weixin.qq.com/debug/sandbox">sandbox</a> (unfortunately, the authentication in the <a href="https://admin.wechat.com/debug/sandbox">English edition</a> seems to be broken, so we will use the Chinese edition).</li><li>Log in by clicking the green button (登录 ‘log in’) and scanning the QR code (you can find the scanner by tapping the ‘+’ on the chat overview).</li><li>Authorize the sandbox by confirming the login on your phone.</li><li>You should be taken to a page that shows your appID and appsecret.</li></ol><p><strong>Step 3: Initialize the Express app</strong></p><p>Create a file index.js and set up a simple Express app:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e79c849d64594ae83804a45db4b8549c/href">https://medium.com/media/e79c849d64594ae83804a45db4b8549c/href</a></iframe><p>This should be enough to test your setup. Go back to the terminal and run Node on the current directory (or index.js):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/56671458701b7f49a7c0ceddff2ec80f/href">https://medium.com/media/56671458701b7f49a7c0ceddff2ec80f/href</a></iframe><p>You should see the message WeChat endpoint listening on port 3000… logged to the terminal. Open a browser and browse to <a href="http://localhost:3000">http://localhost:3000</a>. It should show the simple message ‘WeChat endpoint’.</p><p><strong>Step 4: Connect your app to WeChat</strong></p><p>We will set up the routes that are specific to WeChat in a new file. Create a new file wechat.js, in the same directory as index.js, and set up the Express router in that file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cdf720151df84dd4436da955de7e76a0/href">https://medium.com/media/cdf720151df84dd4436da955de7e76a0/href</a></iframe><p>The first time you set up your server as the endpoint of an Official Account, it needs to respond with an echo string to verify that everything works correctly. WeChat will send a signature, nonce, timestamp and echo string (echostr) to your app with which you can verify that it is indeed WeChat that is connecting. If the signature is correct, you should respond with the echostr. To make this blog post a bit shorter, we will short-circuit this and always return the echostr (in production, you want to make sure that everything is correct though):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b53e01d1cd83c986567ac27f6630f41/href">https://medium.com/media/0b53e01d1cd83c986567ac27f6630f41/href</a></iframe><p>This code will check if an echostr is set as a query parameter and outputs it if it is set. Otherwise, it returns a 404 status code and error message. The logging statements will be shown in the terminal session you used to start up the Node application.</p><p>Before we can test whether our setup is working, we need to tell Express to also load the route in the wechat.js file when starting up in index.js. You can do that by adding the following line to index.js:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/843804b44c360a5b7447a589457c9233/href">https://medium.com/media/843804b44c360a5b7447a589457c9233/href</a></iframe><p>Put this below the app.get(&#39;/&#39;) call we created earlier, above the port definition.</p><p>You are now ready to check if WeChat can reach your application through an ngrok tunnel. If your Node application is still running, kill it with Ctrl-C and then restart it with node .. Make sure there are no errors while starting up and then open a second terminal window. Run ngrok and have it create a tunnel to port 3000 with the following command:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f99f2345311a30b5800668b6b1ed84b2/href">https://medium.com/media/f99f2345311a30b5800668b6b1ed84b2/href</a></iframe><p>After a few seconds you should see the output from ngrok. Copy-paste the second ‘Forwarding’ URL (the https:// one) and paste it in your browser. This should connect without problems. You can open the ngrok web interface if you want (mentioned under the ‘Web Interface’ entry).</p><p>Now go back to the WeChat sandbox page, and log in if necessary. There should be two fields named ‘URL’ and ‘Token’ in the second panel. Append /wechat to the https:// URL of ngrok and paste it in the ‘URL’ field. Then type a random string in the ‘Token’ field (like 123456, the contents don’t matter because we are not checking the signature).</p><p>Click the green button (提交 ‘submit’). You probably get an error. Click the button again. You should now see a 200 OK request coming in on the ngrok dashboard, and the URL and token should be saved in the sandbox. Your account has been set up!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/0*0Lh_9es9z9o13grk.png" /><figcaption>1 — Fill in your ngrok URL and a token (can be anything)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/0*fU-su1GH2XKE6rvY.png" /><figcaption>2 — After clicking the green button twice, this should appear (with your URL and token)</figcaption></figure><p><strong>Step 5: Process incoming messages</strong></p><p>Whenever a user starts following your official accounts, sends a message to your account or unfollows it, you will receive a POST request with some XML describing the message. To handle these messages, we need to add another endpoint to our wechat.js file, but instead of calling app.get() to create a handler for GET requests, we will call app.post() to register a handler for POST requests. As we don’t want to write a lot of XML-parsing boilerplate code ourselves, we will install an XML body parser for Express that can handle this for us. Let’s start with that.</p><p>Install body-parser and body-parser-xml with the following command in your terminal:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/064aa7056026fb8dec8ce25392ddf6d2/href">https://medium.com/media/064aa7056026fb8dec8ce25392ddf6d2/href</a></iframe><p>Let’s set up the body parser. In index.js, change the two top lines (the ones that set up the Express app) so they reflect the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1cf883789163945f1b10afa80f76c5f/href">https://medium.com/media/b1cf883789163945f1b10afa80f76c5f/href</a></iframe><p>This again sets up an Express app but now also installs the body-parser XML middleware which will help us parse the incoming request bodies. Let’s write the POST request handler, below all other code in wechat.js:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e306e5827cf156986de0fc4762df39a/href">https://medium.com/media/3e306e5827cf156986de0fc4762df39a/href</a></iframe><p>This piece of code sets up a POST handler on the router (line 6), takes the parsed XML out of the body and switches over the message type (line 9, the XML parser puts single text nodes into an array so that’s why we need to access it with index 0). The function then forwards the response object and parsed XML to one of three handlers (line 11, 13 and 15), for handling new events, text messages and any messages of unknown type respectively. The last step will involve implementing these handlers and returning an XML response that will be sent to the user.</p><p><strong>Step 6: Write message handlers</strong></p><p>This is the final step of implementing our WeChat echo service! As WeChat requires us to respond with XML, we will use template strings to easily create an XML string that can be written to the response object. WeChat then sends our message to the user’s device, so it feels as if they are talking to an actual person.</p><p>The function for setting up the template is as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/506e97f774fda1e6f93e32531e77d441/href">https://medium.com/media/506e97f774fda1e6f93e32531e77d441/href</a></iframe><p>This will inject the receiver, sender and text content into an XML string that can be sent in the handlers. You should add this function above the handlers, by replacing TODO 3.</p><p>Next, we’ll set up our handlers. The most complex one is the handler for event type messages, as there can be multiple types of events that are triggered. We are only interested in the subscribe event, that is triggered when a user scans your QR code and taps ‘Follow’. This is the handler:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5a5e08a01d666e043e8f1f29c4d6796/href">https://medium.com/media/b5a5e08a01d666e043e8f1f29c4d6796/href</a></iframe><p>The handleEvent function extracts the event type from the XML data and checks if it is a subscribe event. It then creates an XML response by flipping the sender and receiver from the XML data and adding a string message. This will welcome new followers with the ‘Welcome to our Official Account!’ message.</p><p>While we’re at it, let’s implement the other message handlers:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b7acb4e58771e7f61f2bd1cfb978f7d/href">https://medium.com/media/7b7acb4e58771e7f61f2bd1cfb978f7d/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e48bbeb5eabfa5b11111f16217d85a6e/href">https://medium.com/media/e48bbeb5eabfa5b11111f16217d85a6e/href</a></iframe><p>In the handleText function, the string that is sent back is the reversed text message sent by the user. In the handleUnknown function, we just send back a message telling the user that our echo service does not (yet) understand what they’re saying.</p><p>And that’s it! After all the hard work it is time to see what happens when we start to follow our own Official Account and send some messages. To start following yourself, scan the QR code that is shown on the WeChat sandbox page, halfway down. On your phone, tab the ‘+’ at the top-right corner in the chat overview, then tap ‘Scan QR code’. After scanning the code, you should see a simple page with a large ‘Follow’ button. If you tap that, WeChat should open a new chat with the echo service. It should welcome you with the message we added earlier. If you send a text message, the echo service should reply with your message reversed. If you send anything else (a picture maybe, or your location) the echo service will tell you that it doesn’t understand that message type. If this all works, good job!</p><p><strong>Wrap up</strong></p><p>You’ve now seen how you can build a simple application on WeChat using the Official Account debug sandbox. As an exercise, you could try changing the code so the service greets the user with a menu, and based on the user’s response trigger an action like sending a video or image. The <a href="http://admin.wechat.com/wiki/index.php?title=Main_Page">technical documentation of WeChat</a> will help you in figuring out how to handle incoming media files and how to respond to them. Luckily, the ideas are similar to what you have seen so far.</p><p>Also, you could host your Node application somewhere in the cloud so it keeps reacting to new messages. Right now, if you kill your ngrok tunnel and/or Node app, WeChat will show an error to users that sent anything to your sandbox account. You can look into tools like <a href="https://zeit.co/now">Zeit Now</a> to easily deploy your Node app in a more persistent way, or try the <a href="https://aws.amazon.com/">Amazon</a> and <a href="https://cloud.google.com/">Google</a> clouds for easy hosting. After setting up your application elsewhere, don’t forget to change the URL on the sandbox page.</p><p>I hope the implementation of a simple echo service helped you assess whether or not WeChat is the right platform for your business and whether or not it can help you get more traction within the Chinese market. If you decide to go with WeChat, the first steps in this blog post should help you get up and running as quickly as possible. Should you inadvertently need help with the strategic or technical implementation of WeChat for your proposition on the Chinese market, please don’t hesitate to contact us!</p><p><em>This blog post was originally published on the Xebia Blog, available </em><a href="http://blog.xebia.com/no-wechat-no-life-part-3-implementing-echo-service/"><em>here</em></a><em>.</em></p><p><em>Léon Rodenburg is a full stack development consultant at Xebia. He has a background in Computer Science and Sinology and is always on the lookout for the crossroads between the two. Having lived and studied in China for quite some time, he has put his knowledge of the Chinese language into practice by experiencing on- and offline daily life in Beijing like a local.</em></p><p>Some useful links:</p><ul><li><a href="http://mp.weixin.qq.com/debug/sandbox">WeChat sandbox</a> (Chinese, English version <a href="http://admin.wechat.com/debug/sandbox">here</a> but might be broken)</li><li><a href="http://admin.wechat.com/wiki/index.php?title=Main_Page">WeChat technical documentation</a> (English)</li><li><a href="https://itunes.apple.com/nl/app/wechat/id414478124?mt=8">WeChat on the Dutch iOS App Store</a></li><li><a href="https://play.google.com/store/apps/details?id=com.tencent.mm">WeChat on Google Play</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e625151268e6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/xebia/no-wechat-no-life-part-3-implementing-an-echo-service-e625151268e6">Why Your Business Should Be on the WeChat Platform (Part III): Implementing an echo service</a> was originally published in <a href="https://medium.com/xebia">Xebia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Your Business Should Be on the WeChat Platform (Part II): WeChat Feature Overview]]></title>
            <link>https://medium.com/xebia/why-your-business-should-be-on-the-wechat-platform-part-ii-wechat-feature-overview-7b7eae7427ac?source=rss-46dcbcbefdbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b7eae7427ac</guid>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[china]]></category>
            <category><![CDATA[wechat-pay]]></category>
            <category><![CDATA[messaging]]></category>
            <category><![CDATA[wechat]]></category>
            <dc:creator><![CDATA[Léon Rodenburg]]></dc:creator>
            <pubDate>Fri, 02 Mar 2018 13:14:41 GMT</pubDate>
            <atom:updated>2018-03-02T13:14:41.823Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This three-part series explores how Wechat, the Chinese alternative to WhatsApp, is transforming the on- and offline lives of Chinese consumers and forcing companies to reconsider their marketing and sales strategies.</em></p><p><a href="https://medium.com/xebia/why-your-business-should-be-on-the-wechat-platform-b0d89ae81cce"><em>Part I</em></a><em> compares WeChat to WhatsApp and explains why a presence on WeChat matters for any Chinese-facing business. Part II provides an overview of WeChat’s most essential features, describing how it’s typically used day-to-day. It also explains how companies can use WeChat to improve their business in the Chinese market.</em></p><p>WeChat, as the name implies, was first put out on the market as a messaging application, but has rapidly outgrown that label in recent years. In addition to messaging, WeChat boasts three other feature categories: payments, social, and official accounts (OA). All of these features integrate seamlessly into a single platform. And, with the help the APIs WeChat provides, these features can be intertwined to create complete user experiences within the app. If you are interested in creating a WeChat presence for your brand or company, the OA section of this article is most relevant.</p><p>Disclaimer: Some of the functionality discussed here is only available in the Chinese edition of WeChat, so it won’t show up if you install the English version. For this reason, some screenshot examples in this article inevitably contain Chinese, but the subtitles included should help you place the content in context. Depending on your platform, you will get the Chinese version when you have your phone set to Chinese or connect to a Chinese app marketplace. But to quickly start using WeChat, I recommend that you install the English version.</p><h3>Messaging</h3><p><strong>Chat</strong> — WeChat has everything you might expect from a messaging application when it comes to chat functionality. It shows you a list of the most recent (group) chats, an item for collecting all your subscriptions in one place (more on that later), and any companies that you follow that have registered a service account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*Epq2FOv0AI7Brtrigk81gw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*95zsu2ISALDxnWjRXCUcUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*_s4OGJJ3FjPNdI581vdLWA.png" /><figcaption><strong>Figure 1 — </strong>An overview of the most recent chats, groups and subscriptions. <strong>Figure</strong> <strong>2 — </strong>A single chat with “stickers” (animated GIFs). <strong>Figure 3 — </strong>A scannable QR code for adding a new contact.</figcaption></figure><p>In Figure 1, the fourth item on the list comes from Wumart (物美超市), a chain of supermarkets that implemented its loyalty program on WeChat. The fifth item is from Watsons (屈臣氏), a Hong Kong-based health and beauty care store, that did the same. Users can pull up their membership cards through these entries, more on that later.</p><p>Within a chat, you can send text, audio, video, pictures, emoji, animated GIFs (sometimes called “stickers”), location data, and other contacts (Figure 2). You can also send money to contacts or even to groups. Chinese people are much more likely to send audio messages than European texters, as these are more private and information dense. It’s also not not uncommon to see Chinese people hold their mobile phones up to their ears vertically to listen and then horizontally to their mouths to respond, like a walkie-talkie.</p><p>To add new contacts, users usually scan QR codes (Figure 2). You can pull up your QR code through your profile menu (the fourth item in the bottom navigation of Figure 1). The other party can then use the + button (in the top-right corner of Figure 1) to scan your QR “bread slice” (Figure 3), or another image of your choice. It’s also possible to search by name.</p><p><strong>Audio and video calls</strong> — Audio and video calls are comparable to the features offered by WhatsApp, Skype and FaceTime. You can call a contact through the chat or the contact list, which you can reach by tapping the second item in the bottom navigation of Figure 1.</p><h3>Payments</h3><p><strong>Store payments </strong>— You can reach your WeChat wallet (Figure 4) through the profile menu. The wallet prominently shows your balance, a button to pay in a physical store, and a list of linked credit/debit cards. Underneath these, there’s a list of Tencent services and banking-related apps that let you do things like top up your cell phone account or pay your utility bills. You can also invest your money or buy insurances. At the very bottom, there’s a list of other services, like hotels, taxis, bicycles and food, mostly from third-party vendors that have partnered directly with Tencent. Adding an app here is and won’t be covered in this post.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*2asbSWqpDxrf95NJfDGYnA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*a1Rl6Hb9i8Gd2fR_lZnpCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*Jy94RnjEUhcqK3Hf51C-rA.png" /><figcaption><strong>Figure 4 — </strong>Wallet in WeChat. <strong>Figure 5 — </strong>Linked to ICBC debit card, this code allows you to pay in a store. <strong>Figure 6.</strong> Money transfer in a chat.<strong>6 — </strong>Money transfer in a chat.</figcaption></figure><p>If you are at a physical store, you can pull up a barcode to pay using the first button on the top left (Figure 4). The cashier scans your code (Figure 5), and within one or two seconds, the payment succeeds (unless your account is overdrawn, of course). You leave the store without ever taking out your wallet, swiping a card, or filling in a code. This type of payment requires the store to obtain additional capabilities for WeChat Pay and WeChat-branded hardware to scan these codes.</p><p><strong>Transfer money</strong> — As Figure 6 shows, you can transfer money to other people individually or in a group within chats. The group transfer is mostly used during Chinese New Year when people send the infamous “red envelopes” (红包) around. You can set an amount, and it will be divided equally among the group’s members or based on a first-come-highest-amount rate.</p><p>You can also create a QR code that others can scan to transfer money to you without adding you to their contact list. A lot of smaller vendors use this option because it doesn’t require a special WeChat account, plus it’s free. When you want to use WeChat to pay for something in a local shop, these vendors can provide a QR code, either printed or on their phones, for you to scan. Then, you just fill out the amount of money to transfer, authorize the payment and take off with your newly bought goodies.</p><h3>Social</h3><p>When it comes to social media functionality, WeChat feels like a hybrid of Facebook and Instagram with a slimmed down feature set. Called “Moments” in English, this aspect of WeChat translates literally as “friend circle.” You can post text, pictures, and video here. You can also like posts and place comments just as you would with the familiar social media platforms I just mentioned (Figure 7). However, there is one striking difference: the messages and comments you post are only visible to people in your contact list. This potential drawback often creates confusion, since you can’t read the whole thread of comments. For example, a friend may appear to respond to himself when he’s having a conversation with someone not in your contact list. Generally speaking though, it also saves you from the useless spam sometimes seen on other platforms. Plus, the moments you share only reach the audience they were intended for, your friends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*Ju0EIn8l2ympkkU6i7sMjQ.png" /><figcaption><strong>Figure 7 — </strong>Several posts on WeChat’s Moments.</figcaption></figure><h3>Official Accounts (OA)</h3><p>An official account (公众号) is a special type of account on the WeChat platform. Companies use these accounts to get in touch with their customers, both actively and passively. The workflow for these accounts is mostly the same: users can physically scan your QR code from your advertisement, search for your company within WeChat, or get redirected to your account from somewhere else. Your OA shows up in the user’s WeChat as soon as she clicks “follow.” Simultaneously, you receive all the user’s details (Figure 8). There are four types of official accounts, each with its own specifications. Choosing the right type is critical because it cannot be changed once it’s registered.</p><p><strong>Service accounts (服务号)<br></strong>We’ve already looked at two examples of official accounts in the messaging section of this article. Both Wumart and Watsons use their OAs to update followers on discounts, pull people into their mobile websites, and identify customers in their loyalty programs.</p><p>Both examples are service accounts used mostly to offer customer support and build chat-like applications with custom menus on the WeChat platform. The menus often link to the companies’ web applications, which are loaded into a browser view within WeChat. Service accounts have access to advanced features like payments, geolocation and authorization APIs, but can only push messages to users four times a month. An example of these messages is shown in Figure 9, which contains the store’s latest discounts and offers. You can also use these messages to target specific customer groups, such as by age, location, or gender.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*FPOYubBZd2aNv21PdMi6zQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*Kd-jAoa1ugMhEXcGTj1PhA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*0cJu0Bq96bP_wfKITgqp8g.png" /><figcaption><strong>Figure 8 — </strong>The official account of KLM, the Dutch airline, with a green “Follow” button. <strong>Figure 9 — </strong>The chat-like interface of the Watsons OA, with a menu and keyboard on the bottom. <strong>Figure 10 — </strong>The Wumart member card accessed through their OA (as a separate web page).</figcaption></figure><p>There is a JS SDK available that makes it easy to enhance the loaded web pages with native-like mobile features, like taking pictures or getting a user’s location. That only works if the page is loaded through the in-app browser view provided by WeChat. In the case of Wumart and Watsons, the WeChat APIs are used to authenticate so you can show your membership card to the cashier right from within their service accounts (Figure 10). You can host these pages yourself and link your domain name to the official account, so WeChat knows the page is served from the right location.</p><p>Behind the scenes, you have a server in place that receives the messages users send in the chat. You have a 48-hour window to (automatically) respond to the message, if you want to avoid spam. You can also query your own database and return results, or send images, video or coupon codes. You could even build a full-blown customer support dashboard on top of this, in which an actual operator can respond to incoming messages. Part III of this blog series describes how to build your own echo backend with a custom menu that will send all the messages a user sends back to them.</p><p><strong>Subscription accounts (订阅号)</strong> — Subscription accounts are available for individuals and companies. These accounts look a lot like service accounts, but they have a few downsides. For one, they don’t provide access to the more advanced APIs, like payments. Also, your chat appears in a dedicated folder for subscriptions, not at the top of the chat. Subscription accounts do have one advantage over service accounts, however; they can send push messages once per day, instead of four times a month. For individuals that blog a lot or companies that generate content as their main product (news agencies, for example), a subscription account works well for this reason. Otherwise, I don’t recommend them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*BjqCJhMI4Wgz4Lx4rzL2xg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*5ROhTQiGMZv0eKCleWhBlA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*b3tsJSpcUmbun3pstlctBg.png" /><figcaption><strong>Figure 11 — </strong>List of subscriptions, after opening the ‘Subscriptions’ item on chat overview. <strong>Figure 12 — </strong>The technology news items of Sina, pushed to your phone. <strong>Figure 13 — </strong>An opened news item loaded through the in-app browser.</figcaption></figure><p><strong>Mini Programs (小程序)</strong> — In January 2017, Tencent released Mini Programs (MP, 小程序). MPs operate like an app by using WeChat’s SDKs to build a native experience. But they don’t require the user to install an app. An MP can be shared with other contacts and accessed through a QR code. So, it’s a suitable option if you need a heavy user intergace, but don’t want to go the whole nine yards on (cross-platform) native app development. There is a library of UI components you can use in your app to build on so you can get started quickly.</p><p>You can access an MP in two ways. When you pull up all your chats, a list of the most recently accessed MPs appears, along with a button to access the other MPs. The Discover (发现) page, item three in the bottom navigation of Figure 15, also pulls up the other MPs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*LdNY8Jy8b9CpEQ8krwimTA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*ZC5e99R2bgbQwjjRj7ed2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*asfZUi860S87uMx56Qfogw.png" /><figcaption><strong>Figure 14 — </strong>List of MPs at the top, after dragging chats down. <strong>Figure 15 — </strong>The Discover page, with the MPs item as the last in the list. <strong>Figure 16 — </strong>Demo MP, showcasing all UI components and APIs.</figcaption></figure><p><strong>Enterprise accounts (企业号)</strong> — Chinese organizations use this type of account internally to make communication and file sharing easier. Only authorized employees can access the data, so it is not suitable for consumer-facing applications. I won’t discuss this account type any further here, but you can read up on enterprise accounts on the WeChat website.</p><p>Those are WeChat’s most essential features. I’ve left out a lot of others, like meeting people that are close to you, or winning prizes on television by shaking your phone, because those functionalities are not immediately relevant for companies. There are also some features that are most relevant if you have a physical store in China, like granting WeChat users access to your WiFi access point (and consequently have them follow your OA). This article gives you an overview of the most critical features and how you can use them to expand customer support and broaden the customer base of your products.</p><p>In the third and final issue of this blog series, I will explain how developers can start building a service account on WeChat through a sandbox account.</p><p><em>This article was originally published on Xebia Articles, available </em><a href="https://articles.xebia.com/why-your-business-should-be-on-the-wechat-platform-part-ii-wechat-feature-overview-"><em>here</em></a><em>.</em></p><p><em>Léon Rodenburg is a full stack development consultant at Xebia. He has a background in Computer Science and Sinology and is always on the lookout for the crossroads between the two. He lived and studied in China for quite some time, where he put his knowledge of the Chinese language into practice by investigating on- and offline daily life in Beijing, especially regarding technologies like WeChat.</em></p><p>Some useful links (in English):</p><ul><li><a href="https://itunes.apple.com/nl/app/wechat/id414478124?mt=8">WeChat on the Dutch iOS App Store</a></li><li><a href="https://play.google.com/store/apps/details?id=com.tencent.mm">WeChat on Google Play</a></li></ul><h4>Sources</h4><p><a href="https://mp.weixin.qq.com/"><em>https://mp.weixin.qq.com/</em></a><em> (in Chinese)<br></em><a href="http://admin.wechat.com/wiki/index.php?title=JS_SDK_DOCUMENT"><em>http://admin.wechat.com/wiki/index.php?title=JS_SDK_DOCUMENT</em></a><em><br></em><a href="https://mp.weixin.qq.com/debug/wxadoc/design/index.html"><em>https://mp.weixin.qq.com/debug/wxadoc/design/index.html</em></a><em><br></em><a href="https://mp.weixin.qq.com/debug/wxadoc/dev/demo.html?t=1477656485442"><em>https://mp.weixin.qq.com/debug/wxadoc/dev/demo.html?t=1477656485442</em></a><em> (scan code to access the MP)<br></em><a href="https://work.weixin.qq.com/?from=mp_home"><em>https://work.weixin.qq.com/?from=mp_home</em></a><em> (in Chinese)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b7eae7427ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/xebia/why-your-business-should-be-on-the-wechat-platform-part-ii-wechat-feature-overview-7b7eae7427ac">Why Your Business Should Be on the WeChat Platform (Part II): WeChat Feature Overview</a> was originally published in <a href="https://medium.com/xebia">Xebia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Your Business Should Be on the WeChat Platform]]></title>
            <link>https://medium.com/xebia/why-your-business-should-be-on-the-wechat-platform-b0d89ae81cce?source=rss-46dcbcbefdbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0d89ae81cce</guid>
            <category><![CDATA[open-api]]></category>
            <category><![CDATA[wechat]]></category>
            <category><![CDATA[digital-strategy]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[china]]></category>
            <dc:creator><![CDATA[Léon Rodenburg]]></dc:creator>
            <pubDate>Mon, 29 Jan 2018 07:25:26 GMT</pubDate>
            <atom:updated>2018-07-16T11:57:37.630Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine a world without WhatsApp. It probably wouldn’t change much, because WhatsApp has been slow to implement new features that would enable its platform for e-commerce, banking or marketing purposes. In September 2017, the first reports of WhatsApp’s new business-to-consumer (B2C) features arose, with customer support as one of the central axes on which it could swing into the enterprise jungle. This seems to be it for now, as no new reports of other B2C functionality have come out. And, with local and European privacy laws lurking just around the corner, it might take some time before WhatsApp can fly in a B2C context. Until then, WhatsApp will remain just a messaging application.</p><p>So, the absence of WhatsApp wouldn’t change the way you get in touch with the companies you buy products from because this new customer support functionality isn’t widespread yet. And it wouldn’t change the way you do your daily banking because it’s still just a chat app, and it certainly wouldn’t change the way you prove your identity to, say, the government. If WhatsApp went away, you would probably just use an alternative chat application to talk to and message your friends, like Facebook Messenger or Telegram. WhatsApp is only a small part of our daily life, and we need a multitude of other services to get everything else done. Removing one these services doesn’t change everything, we just swap it for an alternative and go back to our daily business.</p><p>You can probably also imagine a world without WeChat (微信), because you most likely haven’t heard much about it. Tencent (腾讯), the Chinese internet giant that’s worth more than Google, released this multi-purpose social media mobile application software back in 2011. Today, it has over 980 million monthly active users (902 million daily active users), and has been called China’s “App for Everything” and the world’s first “Super App.”</p><p>But besides comparing it to messaging applications like WhatsApp and Facebook Messenger, most media coverage on WeChat doesn’t go much deeper than that. Only a handful of news items, blog posts or articles discuss its particular features, and even fewer discuss how to use WeChat in sales and marketing strategies for business. On the implementation side, an English version of the documentation is available, but it is outdated in some areas and completely lacking in others.</p><p>Clearly, WeChat is not much of a thing here, yet, but Tencent’s app did feature in the last Technology Radar by ThoughtWorks. The article puts WeChat in the ‘Trial’ category, which means that it’s worth checking out to determine if it could help your business, but hasn’t gained much traction. In the future, that might change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*ykUsXrqrjMpOh_7rGrog2g.jpeg" /><figcaption>WeChat logo</figcaption></figure><p>To see why, let’s go back to our previous discussion and switch things around a bit. Would the daily life of a Chinese consumer change if we took WeChat out of it? You bet. WeChat has penetrated so many aspects of daily life that the average Chinese consumer is lost without it. From store payments, hotel reservations and online purchases to gym membership cards, frequent flyer statuses, and supermarket discounts, everything is contained in “the one platform to rule them all.”</p><p>Almost all WeChat users are also active on the Instagram-like social media functions that allow you to share pictures with your friends and respond to their funny cat videos. What’s more, it can even be used to officially prove your identity, as it is replacing paper identification in Guangzhou and soon throughout China. More and more Chinese businesses are moving abroad and taking WeChat along with them as their primary marketing platform. So, it is not surprising that WeChat has finally started popping up on the Technology Radar. If we look at the pervasiveness of WeChat in the Chinese market and what it might do in ours, do you think the comparison to WhatsApp is still fair?</p><p>Definitely not. WeChat has surpassed WhatsApp in so many ways that it is hard to see why Facebook didn’t manage to improve their platform earlier. Tencent’s WeChat Open Platform (微信开放平台) already opened its doors for innovative solutions to everyday problems years ago, not just messaging and communication.</p><p>Anyone can step up and open a sales or marketing channel on WeChat. The commercial users range from small street vendors who want to accept payments through WeChat to large retailers that implement a full-blown e-commerce and customer support platform that replaces their webshop. WeChat APIs take away the complexity of authentication, payments and messaging by providing these out-of-the-box, yet with enough flexibility to connect with a customized backend of any larger enterprise. With over 900 million daily active users, it is not hard to see how an effective presence on WeChat can easily double or triple your user base overnight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*3hwnayML8EPRDnda6F5LSw.jpeg" /><figcaption><em>Pay using WeChat at the supermarket (photo by Wendy Steffens)</em></figcaption></figure><p>From a marketing or sales perspective, the pervasiveness of WeChat is precisely its beauty. If you want to increase your visibility on the Chinese market or reach more of the Chinese consumers in your own country, it is imperative that you have a presence on Tencent’s app, because these 900 million users are already accustomed to contacting companies through WeChat.</p><p>The downside is, it can be hard to get started. Especially when it comes to the more advanced features, like payments and location services. If you don’t read Chinese, you are mostly out of luck. Paired with a rather lengthy application process for companies and the fact that you need a locally registered business entity in China should you want to target mainland Chinese users, publishing anything even remotely useful on WeChat can be a daunting task.</p><p>At Xebia, we’ve experienced these difficulties first hand. Over the last few months, we’ve been investigating WeChat’s possibilities and built several applications on top of its APIs. We’re very enthusiastic about the potential and would like to help you get up and running with WeChat quickly. Over the next few weeks, we’ll follow up on this article as a three-part series. <a href="https://medium.com/xebia/why-your-business-should-be-on-the-wechat-platform-part-ii-wechat-feature-overview-7b7eae7427ac">Part two</a> will present the most important features of WeChat, and <a href="https://medium.com/xebia/no-wechat-no-life-part-3-implementing-an-echo-service-e625151268e6">part three</a> will provide a step-by-step guide on how to build your first application on the platform. This series should help you assess whether or not WeChat has something to offer your business. In the meantime, feel free to contact me or Xebia directly about WeChat if you’re interested. Let’s make WeChat a thing here!</p><p><em>This article was originally published on Xebia Articles, available </em><a href="http://your-business-should-be-on-the-wechat-platform"><em>here</em></a><em>.</em></p><p><a href="https://play.google.com/store/apps/details?id=com.tencent.mm&amp;hl=nl">Download WeChat from Google Play</a><br><a href="https://itunes.apple.com/nl/app/wechat/id414478124?mt=8">Download WeChat from Apple App Store</a></p><p>Some useful links (in English):</p><ul><li><a href="http://open.wechat.com/cgi-bin/newreadtemplate?t=overseas_open/cases">WeChat showcases</a></li><li><a href="http://open.wechat.com/cgi-bin/newreadtemplate?t=overseas_open/documentation">WeChat documentation</a></li><li><a href="https://admin.wechat.com/">WeChat Official Account Admin Platform</a></li></ul><h4>Sources</h4><p>Constine, Josh. WhatsApp Announces Free Business App, will Charge Big Enterprises. TechCrunch. September 5, 2017.</p><p>“How WeChat Became China’s App For Everything”. Fast Company. January 2, 2017.</p><p>Kasteleijn, Nando. Chatten en betalen we straks in één app? In China gebeurt het al. NOS. April 10, 2016. (in Dutch)</p><p>Rutherford, Sam. 5 Things to Know About Tencent; The Chinese Internet Giant That’s Worth More Than Facebook Now.Gizmodo. November 27,2017.</p><p>Technology Radar. WeChat. ThoughtWorks. Last accessed on January 14, 2018.</p><p>WeChat Open Platform, documentation</p><p>Wikipedia. WeChat. Last accessed on January 14, 2018.</p><p>Zhao, Christina. WeChat is About to Become the World’s Most Popular Form of ID, but You’ve Probably Never Heard of It. Newsweek. December 28, 2017.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0d89ae81cce" width="1" height="1" alt=""><hr><p><a href="https://medium.com/xebia/why-your-business-should-be-on-the-wechat-platform-b0d89ae81cce">Why Your Business Should Be on the WeChat Platform</a> was originally published in <a href="https://medium.com/xebia">Xebia</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>