Skip to content
How to store values...
 
Notifications
Clear all

How to store values in global variables

3 Posts
3 Users
0 Reactions
4 Views
DrifterOne
(@drifterone)
Posts: 1
New Member
Topic starter
 

Dear Community,

I’ve been working through a persistent issue today and would appreciate any ideas or solutions you might have. (I’m currently on a Pro plan).

I was building a Telegram bot workflow with an AI agent. The goal was to handle both text and voice messages from users. I used a Switch node to either pass the text directly or transcribe the voice message and pass the transcribed result. After the agent processed the input, I wanted to ensure the reply was sent in the same format as the input – either text or voice. To do this, I intended to use another Switch node, referencing the result from the initial input handling to direct the output. However, this didn’t work because the output values were no longer accessible at that point in my workflow.

My next thought was to create a global variable. I planned to set its value to "text" or "voice" based on the input type and then use this variable in the Switch node later. Unfortunately, I discovered that I couldn't even change a variable’s value, which was quite disappointing. I did manage to set a kind of value using a code node at the very beginning of my workflow, and its value persisted until the final Switch node (success!). However, after generating the voice output (using Elevenlabs), the ChatID from the trigger becomes unavailable when attempting to send it via a Telegram Voice note node.

As you can probably tell, I’m feeling a bit frustrated. Perhaps someone here could share an example or offer some assistance; I would be very grateful.

Cheers,
Drfiter

 
Posted : 02/07/2025 4:52 pm
automaxion
(@automaxion)
Posts: 2
New Member
 

I understand how that setup can be challenging.

To address this, the most dependable method within callin.io is to save the input type and Chat ID in the item.json at the beginning of your workflow. You can achieve this using a Function or Set node. For instance, immediately after the trigger, employ a Function node to append inputType (which could be "text" or "voice") and chatId to the item. This ensures these values remain accessible throughout the workflow, allowing you to reference them in later nodes, including your final Switch and Telegram nodes.

Regarding the logic for the reply format, you can confidently use {{$json.inputType}} in your concluding Switch node to direct the appropriate output (text or voice). And for sending the reply, utilize {{$json.chatId}} which you stored earlier in the process.

 
Posted : 02/07/2025 5:14 pm
fahmiiireza
(@fahmiiireza)
Posts: 10
Active Member
 

Why not utilize the initial branching and then maintain them in their own separate branches without merging? This approach ensures a clear separation of concerns between the two.

 
Posted : 02/07/2025 5:34 pm
Share: