Romani Core, v1.1
Posted on

Extendable web service for a running of conversations via Instagram* Direct.
Special processing of a conversation start, an optimization of the conversation processing, a removing of inactive conversations and an improvement of an interaction with outer APIs and the documentation.
* Запрещена в России / Banned in Russia.
Change Log
- Service API:
- Add a stuff for the Postman tool.
- Removing of inactive conversations:
- Store in a database a timestamp:
- of a creation of a conversation;
- of a last message of a conversation.
- Add an API endpoint for a removing of inactive conversations:
- detect them by a timestamp:
- of their creation;
- of their last messages.
- detect them by a timestamp:
- Store in a database a timestamp:
- Outer APIs:
- Return an empty history for a nonexistent thread instead an error.
- Make different types of timestamp fields same in:
- Romani Gate commands:
- sending of a text message to a specified user;
- sending of a link message to a specified user;
- sending of a photo message to a specified user;
- reading of a history of a thread with a specified user;
- Romani Mind commands:
- handling of a part of a history of a thread with an user.
- Romani Gate commands:
- Conversation business logic:
- Process conversations concurrently.
- Start of a conversation:
- Store a flag of a start of a conversation.
- Process an empty history only on a start of a conversation.
Features
- working mode:
- run as a web service;
- control via the RESTful API;
- RESTful API commands:
- start a conversation with a specified user:
- collect users in a database (SQLite);
- protect against duplicate users;
- remove inactive conversations:
- detect them by a timestamp:
- of their creation;
- of their last messages;
- detect them by a timestamp:
- start a conversation with a specified user:
- Romani Gate commands:
- send a text message to a specified user;
- send a link message to a specified user;
- send a photo message to a specified user;
- read an info of a specified user;
- read a history of a thread with a specified user:
- automatic detect a thread ID;
- support a pagination of a history;
- restrict a history by a specified message ID;
- Romani Mind commands:
- handle a part of a history of a thread with an user;
- conversation business logic:
- for each user in a database repeat following steps:
- get an input data:
- via Romani Gate:
- user info;
- new user messages;
- from the database:
- auxiliary data;
- via Romani Gate:
- process the gotten data via Romani Mind;
- save the auxiliary data from Romani Mind to the database;
- send a response from Romani Mind to the user via Romani Gate.
- get an input data:
- for each user in a database repeat following steps:
Architecture
UML component diagram in the PlantUML language:
@startuml
skinparam componentStyle uml2
cloud {
() "Romani Gate API" as RomaniGateAPI
}
cloud {
() "Romani Mind API" as RomaniMindAPI
}
package "Romani Core" {
database "SQLite" {
[Conversations]
}
[Web Server] -up- API
[Web Server] .down.> [Conversations] : add an user
[Web Server] .down.> [Conversations] : remove inactive conversations
[Conversation Loop] .up.> [Conversations] : scan conversations
[Conversation Loop] .up.> [Conversations] : update conversation
[Conversation Loop] .down.> RomaniGateAPI : get_user
[Conversation Loop] .down.> RomaniGateAPI : get_thread
[Conversation Loop] .down.> RomaniGateAPI : get_thread_history
[Conversation Loop] .down.> RomaniGateAPI : send_message
[Conversation Loop] .down.> RomaniGateAPI : send_photo
[Conversation Loop] .down.> RomaniMindAPI : history
}
[Romani Bot] .down.> API : POST /conversations
[cron + cURL] .down.> API : DELETE /conversations
@enduml
Rendered UML component diagram:
Screenshots

POST /conversations endpoint in the Postman tool

DELETE /conversations endpoint in the Postman tool
