WEBVTT

00:00.120 --> 00:08.840
Okay, first up I'm just going to save this as the push workflow workflow.

00:08.960 --> 00:11.920
Save that and go back to personal again.

00:11.920 --> 00:13.080
There is the push workflow.

00:13.080 --> 00:17.400
Create a new workflow to integrate with telegram.

00:17.960 --> 00:20.760
Okay, so this is now just for telegram users.

00:20.760 --> 00:23.080
If you're not a telegram user, don't worry about it.

00:23.120 --> 00:24.400
Telegram is like WhatsApp.

00:24.440 --> 00:27.240
It's like it's just great for this kind of thing.

00:27.480 --> 00:28.640
I'll show you how to do it.

00:28.640 --> 00:31.200
So you see, it is again API key based.

00:31.200 --> 00:32.480
So it's super simple.

00:33.000 --> 00:39.320
If you're in telegram, either on your phone or the app, the first thing to do is to search for a particular

00:39.360 --> 00:40.120
user.

00:40.120 --> 00:43.960
And that particular user is called bot father.

00:43.960 --> 00:45.960
So you do search in the search bar at the top.

00:45.960 --> 00:47.680
You do abbot father.

00:47.880 --> 00:53.840
And it sounds odd, but that that is the thing that gives rise to bots in telegram.

00:53.840 --> 01:00.240
And if you chat with bot father, then you will have a screen a bit like this, which is my telegram,

01:00.360 --> 01:02.200
and I am chatting with bot father.

01:02.200 --> 01:03.360
You see there, that's what it is.

01:03.400 --> 01:10.790
There's 3 million monthly users, and the first thing you do is you do slash forward slash start and

01:10.790 --> 01:13.270
you get like a whole list of different things you could do.

01:13.310 --> 01:17.470
And I'm going to scroll carefully through this because it does show an API key pretty quickly.

01:17.470 --> 01:20.710
But the first thing you do is slash new bot.

01:20.710 --> 01:24.070
And that means I want to create a new telegram bot.

01:24.270 --> 01:27.590
That's what I want to do, and that is what telegram will then do.

01:27.630 --> 01:31.670
Okay, so when you do new bot it says, all right, a new bot, how are we going to call it.

01:31.670 --> 01:33.710
Please choose a name for your bot.

01:33.870 --> 01:41.310
And I've called my one TG underscore underscore convo conversation between telegram and NAMM.

01:41.310 --> 01:46.510
But you can call yours whatever you want and it will create that bot for you.

01:46.750 --> 01:50.190
Now the next thing it says is let's choose a username for your bot.

01:50.230 --> 01:55.350
It must end in bot like Tetris bot or Tetris underscore bot.

01:55.590 --> 02:03.430
So I call mine tg and convo bot and you can call yours whatever you want as long as it ends in bot,

02:03.470 --> 02:04.710
just like it says.

02:04.710 --> 02:06.710
So do that next.

02:06.910 --> 02:10.820
Okay, Next up it says, Don, congratulations on your new bot.

02:10.860 --> 02:13.620
You can find it and it's given like a link to it.

02:13.620 --> 02:17.900
You can now add a description, a profile picture, lots of other stuff.

02:18.060 --> 02:24.500
Just make sure that that you make make sure that it's fully operational before you unleash it on the

02:24.500 --> 02:25.020
wild.

02:25.220 --> 02:31.220
Now I've stopped scrolling now because if I were to scroll a little bit more, you would see the key

02:31.260 --> 02:32.500
that it then gives you.

02:32.540 --> 02:38.220
It sends you the key right here, and you should copy that into the clipboard carefully, making sure

02:38.220 --> 02:41.180
you don't copy extra spaces at the end or beginning or whatever.

02:41.180 --> 02:44.580
But that is the API key that you will be using.

02:45.020 --> 02:47.500
So it's honestly as straightforward as that.

02:47.500 --> 02:52.580
To get your API key for telegram, there is another interface as well that you might have used.

02:52.580 --> 02:57.020
You might have found when you went to Bot Father, you could open that as a separate window, in which

02:57.020 --> 03:02.420
case you see something like this screen right here, which has create new bot as a menu option, but

03:02.420 --> 03:05.300
otherwise you would have much the same experience.

03:05.340 --> 03:09.060
You'd have created your bot and you would have an API key.

03:09.220 --> 03:10.180
Congratulations.

03:10.180 --> 03:12.720
We're ready now to hook it up to N810.

03:12.760 --> 03:14.360
Okay, so here I am in N810.

03:14.400 --> 03:16.880
The first thing I do is I press Create Workflow.

03:16.920 --> 03:19.040
We're going to add a first step.

03:19.240 --> 03:21.840
And for that first step I'm going to type telegram.

03:22.000 --> 03:26.160
I press telegram here and it shows me the different triggers.

03:26.200 --> 03:30.440
These are the different operations that could initiate this workflow.

03:30.560 --> 03:32.960
And I'm going to pick on message.

03:32.960 --> 03:36.440
When there's a message in telegram I want it to launch this workflow.

03:36.480 --> 03:40.240
I press on message and it opens up this telegram node.

03:40.520 --> 03:41.080
Okay.

03:41.360 --> 03:43.600
It begins with a credential to connect with.

03:43.640 --> 03:45.520
You know the drill drop down here.

03:45.520 --> 03:47.520
Create new credential.

03:47.520 --> 03:49.680
It wants an access token.

03:49.840 --> 03:54.760
And of course I'm going to paste in exactly what I copied from within telegram.

03:54.760 --> 03:57.600
And I was careful to copy it exactly as it is.

03:57.800 --> 04:01.240
And when I'm done I press save and it goes green.

04:01.440 --> 04:03.240
Connection tested successfully.

04:03.240 --> 04:05.040
Hopefully yours went green too.

04:05.240 --> 04:06.200
Congrats.

04:06.240 --> 04:07.200
Back we go.

04:07.240 --> 04:08.560
No thank you LastPass.

04:08.680 --> 04:11.160
Okay, we have set up our trigger.

04:11.200 --> 04:12.760
That's the first step.

04:12.800 --> 04:14.750
And the second step is quick and easy.

04:14.790 --> 04:22.190
You know it well, I press, plus I go to AI, I go to AI agent, I press escape, I want the chat model

04:22.230 --> 04:23.470
to be OpenAI.

04:24.030 --> 04:24.910
There it is.

04:25.230 --> 04:30.830
Escape memory, the simple memory escape and no tools.

04:31.110 --> 04:33.350
Oh, why don't we give it the current date?

04:33.350 --> 04:34.750
We'll give it the current date again.

04:34.790 --> 04:36.230
Date, date and time.

04:36.270 --> 04:36.750
Tool.

04:36.990 --> 04:38.670
Uh, current date.

04:38.670 --> 04:39.630
All sounds good.

04:39.670 --> 04:40.430
Press escape.

04:40.430 --> 04:40.950
There we go.

04:40.990 --> 04:41.950
It's got a tool.

04:42.430 --> 04:45.350
All right, now it's time to add something to the right.

04:45.390 --> 04:48.150
Okay, so next up, I press this plus button here.

04:48.430 --> 04:51.750
This is saying what should the output from this agent do.

04:51.790 --> 04:53.030
What happens next.

04:53.030 --> 04:54.630
So we type telegram.

04:54.830 --> 04:56.430
You're like really telegram twice.

04:56.470 --> 04:57.030
Yes.

04:57.270 --> 05:00.830
This time we press telegram and we're looking at actions not triggers.

05:00.830 --> 05:03.070
These are things that could happen at this point.

05:03.110 --> 05:07.070
And the action we're going to pick is send a text message.

05:07.430 --> 05:08.390
Wow okay.

05:08.630 --> 05:09.790
Select the credential.

05:09.790 --> 05:12.230
Well it's already defaulted to the same thing we just set up.

05:12.230 --> 05:13.950
You don't need to set up credentials twice.

05:14.110 --> 05:18.620
We want to send a message and the the, uh, the text.

05:18.660 --> 05:24.060
We want this text to be the output from the previous cell.

05:24.300 --> 05:25.500
The previous node.

05:25.740 --> 05:26.060
Okay.

05:26.100 --> 05:27.100
How's that going to look?

05:27.380 --> 05:28.980
Something to puzzle over for a second.

05:29.020 --> 05:34.660
There's an added complexity as well, which is that when when we're conversing with telegram, we want

05:34.700 --> 05:40.500
to make sure that whatever we send back to telegram is part of the same conversation that that triggered

05:40.500 --> 05:46.540
us in the first place, and that conversation has associated with it a chat ID, and we need to pass

05:46.540 --> 05:52.580
that chat ID in as well in order that this response goes in the right conversation.

05:52.900 --> 05:55.420
So there's some fiddly stuff to be done here.

05:55.940 --> 06:01.300
Now, the easiest way to find this out is to actually first just give this thing a try without filling

06:01.300 --> 06:03.540
these things in and see what happens.

06:03.580 --> 06:06.860
And then we'll use that to fix it and make it work well.

06:06.860 --> 06:09.700
So that's the first step we're going to we're going to save this as it is.

06:09.740 --> 06:12.660
We're going to come back here to the previous step.

06:12.660 --> 06:14.420
And we're just going to give this thing a try.

06:14.460 --> 06:17.260
And giving it a try is going to turn out to be easier said than done.

06:17.380 --> 06:24.130
The first thing we'll need to do is hover over this node here that the send text message and find this

06:24.130 --> 06:28.130
power button that appears above it and turn it off, deactivate it.

06:28.130 --> 06:29.170
A line goes through it.

06:29.210 --> 06:30.010
It's off.

06:30.010 --> 06:34.210
And do the same with the memory one to the power button, because the memory is going to get in our

06:34.210 --> 06:34.490
way.

06:34.690 --> 06:35.770
So turn that off.

06:36.050 --> 06:40.250
And now what we're going to do is press the Execute workflow button.

06:40.370 --> 06:43.530
And when you press that it starts listening for telegram.

06:43.530 --> 06:50.530
And it might error right away, or it might need you to first of all go to telegram and open up this,

06:50.570 --> 06:54.450
which is an actual chat with the thing that you've created.

06:54.450 --> 07:00.330
In my case, I called it TG convo, and then I'm going to press the start button.

07:00.330 --> 07:03.490
And as soon as I try and start and do something, bam!

07:03.530 --> 07:04.650
It goes wrong.

07:04.650 --> 07:06.850
And what we're now going to do is fix it.

07:06.850 --> 07:11.850
So the thing that's gone wrong is you can see no prompt specified angrily here.

07:11.850 --> 07:17.490
And if I double click on AI agent it, up comes this quite busy screen and we get to see what's actually

07:17.530 --> 07:25.640
happening here on the left is the information that has flown in from Telegram and you can see that it's

07:25.640 --> 07:26.360
Jason.

07:26.360 --> 07:27.320
Recognize this?

07:27.360 --> 07:28.280
It's Jason.

07:28.480 --> 07:33.320
It's a list of objects which have various keys and values.

07:33.320 --> 07:37.280
And some of those things like message is itself an object.

07:37.320 --> 07:39.280
Hopefully this is like click for you.

07:39.280 --> 07:47.120
So this is data in the form of JSON because we've selected the JSON representation coming in from telegram.

07:47.480 --> 07:52.600
And this is the prompt that is being determined for our AI agent.

07:52.600 --> 08:00.400
And what it's looking for is JSON, which means the incoming stuff dot chat input, but there is no

08:00.440 --> 08:03.480
dot chat input here that doesn't exist.

08:03.480 --> 08:09.160
So this thing here, this prompt which is choosing how do I pluck out of here the information that will

08:09.160 --> 08:11.240
go to the AI isn't right.

08:11.240 --> 08:14.920
It's thinking that this is some sort of chat interface and it's coming from telegram.

08:14.920 --> 08:21.440
We need to fix that so that the right information goes to our AI, and the right information is staring

08:21.440 --> 08:22.480
at us right here.

08:22.480 --> 08:25.760
The right information is this text.

08:25.920 --> 08:32.820
That right there is the information, the value here, which at the moment is slash start, uh, is

08:32.820 --> 08:36.060
what the information we wanted to come in to our LM.

08:36.300 --> 08:41.140
And so this is what we really want to be in this in this field right here.

08:41.380 --> 08:42.780
So how do we do that.

08:42.820 --> 08:45.780
Well you see where it says source for prompt.

08:46.020 --> 08:49.860
It thinks we're trying to connect to a chat trigger node which we're not.

08:49.900 --> 08:53.020
It's a telegram node not a chat trigger node.

08:53.220 --> 08:57.140
You drop here and you come down to define below.

08:57.260 --> 09:01.380
Use an expression to reference data in previous nodes.

09:01.380 --> 09:02.980
That's exactly what we want.

09:03.140 --> 09:07.540
We select this and now this box is ready for something to be put into it.

09:07.820 --> 09:11.460
Now we click and hold on on here this slash start.

09:11.700 --> 09:12.940
And we put it in there.

09:12.940 --> 09:20.700
And we let go and look at what appears dollar JSON which means this dot message text.

09:20.940 --> 09:22.380
It's drilling into message.

09:22.380 --> 09:25.100
It's drilling into text to get you that.

09:25.100 --> 09:28.980
And it's put it in two curly braces, which means it's an expression.

09:29.220 --> 09:35.210
And similarly you could just type this in like that and you can see that the result is this text slash

09:35.250 --> 09:38.450
start, which isn't actually going to be all that meaningful to our LLM.

09:38.490 --> 09:41.290
But at least that is in fact what we typed in telegram.

09:41.290 --> 09:45.450
So we now see that what we typed in telegram has made its way in here.

09:45.730 --> 09:46.370
Okay.

09:46.530 --> 09:47.450
Progress.

09:47.490 --> 09:48.930
Let's see how this works.

09:48.930 --> 09:49.290
All right.

09:49.290 --> 09:51.490
So I'm going to press Execute Workflow.

09:51.490 --> 09:52.650
And it's now executing.

09:52.650 --> 09:53.850
And now I'm going to telegram.

09:53.850 --> 09:55.410
And I'm typing hi there.

09:55.810 --> 09:58.850
And I'm pressing um enter.

09:58.890 --> 09:59.570
Hi there.

09:59.690 --> 10:00.290
Off it goes.

10:00.290 --> 10:01.250
It's doing its thing.

10:01.290 --> 10:03.290
Workflow executed successfully.

10:03.290 --> 10:05.890
Let's double click on AI agent and see what happens.

10:06.130 --> 10:08.410
So in it came you can see text.

10:08.450 --> 10:09.970
Hi there right there.

10:10.170 --> 10:11.810
This is where it plucked it out.

10:11.850 --> 10:12.370
Hi there.

10:12.370 --> 10:15.890
Went to our LLM and it said hello how can I assist you today.

10:16.090 --> 10:17.410
And so it worked.

10:17.410 --> 10:22.810
We were able to pluck out the input from this and we used expressions to do it.

10:22.850 --> 10:24.250
We define the expression.

10:24.250 --> 10:25.250
And there it was.

10:25.290 --> 10:27.690
And we could just drag and drop to get that over there.

10:27.890 --> 10:29.570
Hopefully that connected for you.

10:29.570 --> 10:33.890
This is a bit more of an in-depth, uh, integration, but it's working.
