![]()
This article will document the process of setting up a LINE bot to receive conversations and pass them to ChatGPT, and ultimately return the responses back to the user interface.
本文將紀錄實際設置一個LINE bot來接收對話, 並將對話拋給ChatGPT, 最終回傳到使用者介面的過程
架構

Key steps:
1. Apply as a LINE developer and create a Channel.
2. Write an API to handle user interactions with the bot, allowing it to receive and process conversations.
3. Forward the conversation to the ChatGPT API for processing.
4. Receive the processed response from the ChatGPT API and send it back to LINE for the user.
----


----



----
During the development process, you can first deploy the API to a public network, allowing LINE to verify and test it to confirm whether calls are successful. My approach is to have the webhook API receive LINE's text messages and mirror the responses, enabling me to ensure that both receiving and sending are working smoothly.
開發過程中可以先將API發佈到公開網路中,讓LINE驗證並自行測試確認看看使否有呼叫成功, 我的作法是讓webhook API 接收到LINE的文字訊息後, 鏡像回覆, 讓我可以確認接收及發送都是通暢的

Next, I will process the middle of the conversation using the ChatGPT API. In my case, I hope to use it as an interpreter to help me with translations. Therefore, I will provide translation prompts within the API.

Thank you for reading, and I hope it's helpful to you.