Okay, first up I'm just going to save this as the push workflow workflow.
Save that and go back to personal again.
There is the push workflow.
Create a new workflow to integrate with telegram.
Okay, so this is now just for telegram users.
If you're not a telegram user, don't worry about it.
Telegram is like WhatsApp.
It's like it's just great for this kind of thing.
I'll show you how to do it.
So you see, it is again API key based.
So it's super simple.
If you're in telegram, either on your phone or the app, the first thing to do is to search for a particular
user.
And that particular user is called bot father.
So you do search in the search bar at the top.
You do abbot father.
And it sounds odd, but that that is the thing that gives rise to bots in telegram.
And if you chat with bot father, then you will have a screen a bit like this, which is my telegram,
and I am chatting with bot father.
You see there, that's what it is.
There's 3 million monthly users, and the first thing you do is you do slash forward slash start and
you get like a whole list of different things you could do.
And I'm going to scroll carefully through this because it does show an API key pretty quickly.
But the first thing you do is slash new bot.
And that means I want to create a new telegram bot.
That's what I want to do, and that is what telegram will then do.
Okay, so when you do new bot it says, all right, a new bot, how are we going to call it.
Please choose a name for your bot.
And I've called my one TG underscore underscore convo conversation between telegram and NAMM.
But you can call yours whatever you want and it will create that bot for you.
Now the next thing it says is let's choose a username for your bot.
It must end in bot like Tetris bot or Tetris underscore bot.
So I call mine tg and convo bot and you can call yours whatever you want as long as it ends in bot,
just like it says.
So do that next.
Okay, Next up it says, Don, congratulations on your new bot.
You can find it and it's given like a link to it.
You can now add a description, a profile picture, lots of other stuff.
Just make sure that that you make make sure that it's fully operational before you unleash it on the
wild.
Now I've stopped scrolling now because if I were to scroll a little bit more, you would see the key
that it then gives you.
It sends you the key right here, and you should copy that into the clipboard carefully, making sure
you don't copy extra spaces at the end or beginning or whatever.
But that is the API key that you will be using.
So it's honestly as straightforward as that.
To get your API key for telegram, there is another interface as well that you might have used.
You might have found when you went to Bot Father, you could open that as a separate window, in which
case you see something like this screen right here, which has create new bot as a menu option, but
otherwise you would have much the same experience.
You'd have created your bot and you would have an API key.
Congratulations.
We're ready now to hook it up to N810.
Okay, so here I am in N810.
The first thing I do is I press Create Workflow.
We're going to add a first step.
And for that first step I'm going to type telegram.
I press telegram here and it shows me the different triggers.
These are the different operations that could initiate this workflow.
And I'm going to pick on message.
When there's a message in telegram I want it to launch this workflow.
I press on message and it opens up this telegram node.
Okay.
It begins with a credential to connect with.
You know the drill drop down here.
Create new credential.
It wants an access token.
And of course I'm going to paste in exactly what I copied from within telegram.
And I was careful to copy it exactly as it is.
And when I'm done I press save and it goes green.
Connection tested successfully.
Hopefully yours went green too.
Congrats.
Back we go.
No thank you LastPass.
Okay, we have set up our trigger.
That's the first step.
And the second step is quick and easy.
You know it well, I press, plus I go to AI, I go to AI agent, I press escape, I want the chat model
to be OpenAI.
There it is.
Escape memory, the simple memory escape and no tools.
Oh, why don't we give it the current date?
We'll give it the current date again.
Date, date and time.
Tool.
Uh, current date.
All sounds good.
Press escape.
There we go.
It's got a tool.
All right, now it's time to add something to the right.
Okay, so next up, I press this plus button here.
This is saying what should the output from this agent do.
What happens next.
So we type telegram.
You're like really telegram twice.
Yes.
This time we press telegram and we're looking at actions not triggers.
These are things that could happen at this point.
And the action we're going to pick is send a text message.
Wow okay.
Select the credential.
Well it's already defaulted to the same thing we just set up.
You don't need to set up credentials twice.
We want to send a message and the the, uh, the text.
We want this text to be the output from the previous cell.
The previous node.
Okay.
How's that going to look?
Something to puzzle over for a second.
There's an added complexity as well, which is that when when we're conversing with telegram, we want
to make sure that whatever we send back to telegram is part of the same conversation that that triggered
us in the first place, and that conversation has associated with it a chat ID, and we need to pass
that chat ID in as well in order that this response goes in the right conversation.
So there's some fiddly stuff to be done here.
Now, the easiest way to find this out is to actually first just give this thing a try without filling
these things in and see what happens.
And then we'll use that to fix it and make it work well.
So that's the first step we're going to we're going to save this as it is.
We're going to come back here to the previous step.
And we're just going to give this thing a try.
And giving it a try is going to turn out to be easier said than done.
The first thing we'll need to do is hover over this node here that the send text message and find this
power button that appears above it and turn it off, deactivate it.
A line goes through it.
It's off.
And do the same with the memory one to the power button, because the memory is going to get in our
way.
So turn that off.
And now what we're going to do is press the Execute workflow button.
And when you press that it starts listening for telegram.
And it might error right away, or it might need you to first of all go to telegram and open up this,
which is an actual chat with the thing that you've created.
In my case, I called it TG convo, and then I'm going to press the start button.
And as soon as I try and start and do something, bam!
It goes wrong.
And what we're now going to do is fix it.
So the thing that's gone wrong is you can see no prompt specified angrily here.
And if I double click on AI agent it, up comes this quite busy screen and we get to see what's actually
happening here on the left is the information that has flown in from Telegram and you can see that it's
Jason.
Recognize this?
It's Jason.
It's a list of objects which have various keys and values.
And some of those things like message is itself an object.
Hopefully this is like click for you.
So this is data in the form of JSON because we've selected the JSON representation coming in from telegram.
And this is the prompt that is being determined for our AI agent.
And what it's looking for is JSON, which means the incoming stuff dot chat input, but there is no
dot chat input here that doesn't exist.
So this thing here, this prompt which is choosing how do I pluck out of here the information that will
go to the AI isn't right.
It's thinking that this is some sort of chat interface and it's coming from telegram.
We need to fix that so that the right information goes to our AI, and the right information is staring
at us right here.
The right information is this text.
That right there is the information, the value here, which at the moment is slash start, uh, is
what the information we wanted to come in to our LM.
And so this is what we really want to be in this in this field right here.
So how do we do that.
Well you see where it says source for prompt.
It thinks we're trying to connect to a chat trigger node which we're not.
It's a telegram node not a chat trigger node.
You drop here and you come down to define below.
Use an expression to reference data in previous nodes.
That's exactly what we want.
We select this and now this box is ready for something to be put into it.
Now we click and hold on on here this slash start.
And we put it in there.
And we let go and look at what appears dollar JSON which means this dot message text.
It's drilling into message.
It's drilling into text to get you that.
And it's put it in two curly braces, which means it's an expression.
And similarly you could just type this in like that and you can see that the result is this text slash
start, which isn't actually going to be all that meaningful to our LLM.
But at least that is in fact what we typed in telegram.
So we now see that what we typed in telegram has made its way in here.
Okay.
Progress.
Let's see how this works.
All right.
So I'm going to press Execute Workflow.
And it's now executing.
And now I'm going to telegram.
And I'm typing hi there.
And I'm pressing um enter.
Hi there.
Off it goes.
It's doing its thing.
Workflow executed successfully.
Let's double click on AI agent and see what happens.
So in it came you can see text.
Hi there right there.
This is where it plucked it out.
Hi there.
Went to our LLM and it said hello how can I assist you today.
And so it worked.
We were able to pluck out the input from this and we used expressions to do it.
We define the expression.
And there it was.
And we could just drag and drop to get that over there.
Hopefully that connected for you.
This is a bit more of an in-depth, uh, integration, but it's working.