(Image from: LINE Developer News )
Preface
The Icon Switch feature, which was mentioned in the TECHPULSE 2018 presentation, received a lot of inquiries from developers at the time. However, because the Icon Switch API was still considered a Partner API (meaning that only developers who applied for cooperation with LINE could use the feature), not many developers could use it.
I am very happy that this feature is finally open to all developers. This article will use a simple example to let developers understand how to use this feature.
Sample Code
https://github.com/kkdai/line-bot-icon-switch
How to deploy the sample code:
Go to LINE Developer Console to create the relevant Provider and Channel
-
Go to LINE Developer Console to create a LINE Messaging API Channel and enable the Message API function, and remember the following two pieces of information:
- Channel Secret
- Channel Token
-
Go to https://github.com/kkdai/line-bot-icon-switch and click Heroku Deploy to create the account and deploy the service. You will need to enter three pieces of information:
- CHANNEL_SECRET
- CHANNEL_TOKEN
Remember to add
https://test-api-1234.herokuapp.com/callbackto the LINE chatbot web hook to correctly start the chatbot.
Run a real example (demo)
- First, deploy the sample project, or directly add the test bot @656gvdsu (you can also scan the QR Code below)
Enter any word, and the chatbot will prompt you to choose who to reply to: "Brown", "Cony", or "Sally".
Enter "Brown", "Cony", or "Sally", and you will see the bot change its icon and nickname to reply to you.
Code Explanation
(Note: Related code is demonstrated via Go)
{
"type": "text",
"text": "Hello, I am Cony!!",
"sender": {
"name": "Cony",
"iconUrl": "https://line.me/conyprof"
}
}
This example, taken from the Icon Switch documentation, shows that the Message Object has added a sendeer object, which contains two pieces of data:
-
name: The modified nickname, but please note "avoid confusing users", so the full name will be displayed as"Nickname from OA Name", which confirms that the speaker is an official account (not a real person), making it less likely for users to be confused. -
iconUrl: The modification of the icon, the source of the image must be HTTPS.
Finding LINE Friends Icons
You can refer to this LINE Sticker document for related icon sources. In this document, you can find publicly available and free stickers (please note that, except for these open ones, others require verification and purchase to be seen in the LINE window).
Sending a nickname modification
This example code shows how to use the Icon Switch function, and the most important part is the following:
linebot.NewTextMessage("Hi, this is "+message.Text+", Nice to meet you.").WithSender(sendr)
That is, every time you send a message, you need to specify the sender's related information WithSender().
How to use Icon Switch to promote your official account
Next, I will introduce a few application scenarios that may be very suitable for using the Icon Switch function.
Customer service can provide a better experience for users through Icon Switch
For example, a bank's customer service official account can use Icon Switch to switch icons to represent a transition to a real customer service if users want "real customer service" to help during the chat.
LINE official account activities or games through Icon Switch
Some people have the idea of playing some online games through LINE Bot. Through Icon Switch, users can more easily understand who they are talking to. Or the current game status.
For example: Werewolf type games, board games, and other related types.
In addition, through Icon Switch, you can also make some activity announcements, making users feel more friendly:
- Send Mid-Autumn Festival offers through Chang'e
- Send Chinese New Year activity messages through Nian Shou
Conclusion
Icon Switch is a free and very impactful feature for users. I hope that developers can work together to use their creativity to develop creative LINE Bots.
"Create WoW for the world!"




Top comments (0)