I was thinking about improving our support using a bot, and the idea of leveraging Glific struck me as a great option.
The concept is simple: use Glific as a platform to run a bot that can execute flows. This way, the bot’s interactions can appear as a conversation within a thread on Discord.
Here’s the basic plan: when a new thread is created, initiate a flow in Glific. To determine the starting point of the flow, we can use something we already have – Simulators, which are fake contacts created for testing purposes.
By simulating calls and imitating real users in Glific, we should theoretically be able to run flows on Discord.
Next came the testing and creating a quick Proof of Concept (POC). After exploring various libraries, especially those for checking WebSocket connections, I discovered that Apollo Client can run on the server with different configurations. This made it relatively straightforward to adapt the frontend code for queries and subscriptions and integrate everything with Discord APIs.
The steps involved were:
- Obtain an access token using the login API in Glific.
- When a new thread is created, start a flow with that message and proceed.
- Use subscriptions to receive real-time messages and update on Discord.
- Forward the Discord messages to Glific using the Simulator API, and there you go – the ability to run flows on Discord is achieved.
This approach opens up various possibilities:
- Improving support by creating flows that mimic human interaction.
- Sending WhatsApp messages to the internal team from Discord.
While there’s room for improvement in the implementation, I’ll leave that for another time. The main point is that this concept works, and I’ll leave it to others to decide if it’s useful enough to be further developed.
Final result:
