Proactive messaging with Kafka

%3CLINGO-SUB%20id%3D%22lingo-sub-2959345%22%20slang%3D%22en-US%22%3EProactive%20messaging%20with%20Kafka%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2959345%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EI'm%20trying%20to%20send%20proactive%20messages%20in%20NODEJS%2C%20and%20I%20know%20how%20it%20could%20be%20done%20once%20you%20start%20it%20from%20an%20event%2C%20like%20for%20example%2C%20a%20user%20join%20a%20channel%2C%20or%20even%20on%20a%20onMessage()%20event%2C%20where%20you%20can%20get%20the%20context%20and%20then%20get%20a%20list%20of%20users%20and%20finally%20send%20then%20some%20message.%20It%20is%20pretty%20clear%20on%20the%20docs.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EBut%20I%20have%20a%20different%20scenario.%20I%20intend%20to%20get%20a%20message%2C%20and%20then%20send%20it%20to%20a%20broker%20like%20Apache%20Kafka.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EOnce%20it%20is%20done%2C%20I%20will%20subscribe%20my%20bot%20to%20another%20topic%20in%20Apache%20Kafka%2C%20and%20then%20I%20will%20send%20it%20back%20to%20the%20user.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20will%20try%20to%20summarize%20my%20issue%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20get%20a%20message%20by%20using%20the%20onMessage()%20event%2C%20and%20instead%20of%20reply%20that%20message%20strait%20foward%20I%20send%20it%20to%20Apache%20Kafka%20to%20be%20processed%3B%20by%20this%20time%20I%20will%20lost%20the%20context.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ELater%20when%20Apache%20Kafka%20processed%20the%20answser%20to%20be%20sent%20to%20the%20user%20I%20don't%20have%20the%20context%20anymore.%20But%20I%20could%20store%20de%20userID%20and%20TenantID%20and%20try%20to%20recreat%20the%20context%20and%20then%20simplely%20send%20it.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EMy%20problem%20is%3A%20I%20have%20no%20idea%20how%20to%20get%20the%20context%20outside%20of%20an%20event%2C%20even%20if%20I%20have%20the%20user%20and%20tenant%20id.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EI've%20made%20a%20diagram%20in%20order%20to%20make%20it%20clear%2C%20I%20hope%20it%20does.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ECould%20you%20help%20me%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThanks%20in%20advance.%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Paulo175_1-1636736913992.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F326667iB55C055B72AD08DF%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Paulo175_1-1636736913992.png%22%20alt%3D%22Paulo175_1-1636736913992.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2959345%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBots%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMessaging%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

I'm trying to send proactive messages in NODEJS, and I know how it could be done once you start it from an event, like for example, a user join a channel, or even on a onMessage() event, where you can get the context and then get a list of users and finally send then some message. It is pretty clear on the docs.

 

But I have a different scenario. I intend to get a message, and then send it to a broker like Apache Kafka.

 

Once it is done, I will subscribe my bot to another topic in Apache Kafka, and then I will send it back to the user.

 

I will try to summarize my issue:

 

I get a message by using the onMessage() event, and instead of reply that message strait foward I send it to Apache Kafka to be processed; by this time I will lost the context.

 

Later when Apache Kafka processed the answser to be sent to the user I don't have the context anymore. But I could store de userID and TenantID and try to recreat the context and then simplely send it.

 

My problem is: I have no idea how to get the context outside of an event, even if I have the user and tenant id.

 

I've made a diagram in order to make it clear, I hope it does.

 

Could you help me?

 

Thanks in advance.

 

Paulo175_1-1636736913992.png

 

0 Replies