How to Connect Two LINE Chatbots - Seamless Switching with Sub-scenarios
Description
This article explains how to connect two LINE chatbots using the sub-scenario feature. With this approach, you can make your business processes more flexible and complete. We will cover implementation methods, setup steps, and key considerations.
Why Connect Two LINE Chatbots?
Connecting two LINE chatbots offers several benefits:
- Modular Functions: Each bot can handle specific business logic, making the system easier to maintain.
- Flexible Expansion: Easily integrate new chatbot functionalities as needed.
- Resource Optimization: Utilize different bots for different scenarios to improve resource efficiency.
Implementation Method
Preparation
The sub-scenario feature temporarily pauses the current scenario and calls other HTTP methods. This method is similar to the integration of native LINE customer service previously discussed.
Step 1: Generate Encryption Key
- Go to the text template testing section.
- Enter your LINE secret in
{{Utils.encrypt('xxx')}}
to generate the encryption key and copy it.
If you’re unsure how to find your LINE secret, refer to the guide: Setting Up LINE Webhook.
Step 2: Configure Resource Node
In the resource node, configure the following:
- Fill in the third-party webhook URL.
- Generate the
x-line-signature
value using this format:{{Utils.generateSignature('{"events":['+data.conversation._message.raw_event+']}',Utils.decrypt('Your Encrypted Bot Key'),'HMACSHA256')}}
- Set the event request path to
events[0]
in Body Params. - Use
{"events":[{}]}
as the Payload.
Step 3: Define the Process Flow
You need to set up two main processes:
-
Transfer Process:
-
Current Process:
Step 4: Configure Sub-scenario
In the sub-scenario configuration:
- Use a listening node for the
transfer_webhook
scenario node. - Name the sub-scenario node as
sub_transfer
(customizable). - Set trigger conditions for the listening node, such as ending the node when the inquiry equals
[wake_up]
.
Real-world Demonstration
The following image shows the user interface before and after switching between bots. Users can click the “Back” button to return to the first chatbot:
Key Considerations
- Consistent Channel ID: Both chatbots must use the same channel ID.
- Feature Limitations:
- Only text and attachments are supported for transfer.
- Events like
follow
andunfollow
are not forwarded.
- Use Case: This method is primarily for extending existing systems to call other bots, rather than being a feature specifically designed for connecting multiple chatbots.
Conclusion
Connecting two LINE chatbots significantly enhances process flexibility and creates a more comprehensive service. Using sub-scenarios, you can easily implement seamless transitions between chatbots, improving the user experience. Be mindful of the limitations and configuration requirements to ensure proper system operation during implementation.