WEBVTT

00:00.120 --> 00:01.760
And now it's a bigger deal.

00:01.760 --> 00:06.760
We're going to hook up the output of the agent to send messages back to telegram.

00:06.960 --> 00:07.720
How are we going to do this?

00:07.720 --> 00:13.920
We'll start by taking the putting the power back on again of this, of this node and double click so

00:13.920 --> 00:15.160
that we're looking at this node.

00:15.160 --> 00:21.920
And remember we need to fill in a chat ID and text to send the message back to telegram and to give

00:21.920 --> 00:23.160
it the right chat ID.

00:23.160 --> 00:26.000
So it comes back to the person that asked the question.

00:26.280 --> 00:28.880
That's the final part of hooking up our integration.

00:29.520 --> 00:30.800
Let's start with text.

00:31.040 --> 00:36.760
So you can see over to the right here that there's this toggle between fixed and expression.

00:36.760 --> 00:37.840
And this is the key.

00:38.000 --> 00:43.360
This is where we choose between always posting a fixed bit of text like bananas and just that always

00:43.360 --> 00:44.960
being the response in telegram.

00:45.000 --> 00:46.000
We don't want to do that.

00:46.360 --> 00:51.880
We want it to be something that is populated based on what has come in from the AI.

00:52.440 --> 00:53.840
So what's come in from the AI?

00:53.880 --> 00:58.920
Well, it's written over here, it's JSON, it's look, it's this, this, this list of the single thing

00:58.920 --> 01:03.370
here, this object and that object has a single key value pair.

01:03.690 --> 01:06.210
A key is output and the value is.

01:06.210 --> 01:06.570
Hello.

01:06.570 --> 01:07.730
How can I assist you today?

01:08.090 --> 01:08.890
That's what we want.

01:08.930 --> 01:09.730
We want that.

01:10.010 --> 01:10.890
So how do we do this.

01:10.890 --> 01:14.010
Well it's it's just a matter of clicking on expression.

01:14.010 --> 01:15.290
We want an expression.

01:15.330 --> 01:16.010
Have a think about.

01:16.010 --> 01:20.130
If you think of the expression we would want how do you describe expressions.

01:20.130 --> 01:22.210
It's with two sets of curly braces.

01:22.250 --> 01:25.770
If you type two opens it does two closes for you automatically.

01:25.770 --> 01:26.530
We have it.

01:26.570 --> 01:28.410
We have to type an expression in there.

01:29.530 --> 01:31.130
It's already suggesting what we want.

01:31.170 --> 01:37.810
And partly we want to start with dollar JSON, which means the JSON object that's coming in okay.

01:38.090 --> 01:42.250
And now that dollar JSON, it has a single field called output.

01:42.250 --> 01:43.330
That's what we want.

01:43.330 --> 01:45.610
So we type dot output.

01:45.930 --> 01:49.530
And when we type that you can see in the result it tells you it gives you this hint.

01:49.530 --> 01:50.610
This is what it would be.

01:50.650 --> 01:50.970
Hello.

01:50.970 --> 01:52.090
How can I assist you today.

01:52.250 --> 01:52.930
That's perfect.

01:52.930 --> 01:53.850
That's what we want.

01:54.170 --> 02:00.030
And so just by clicking here you can see I have now hooked it up so that the text that goes back to

02:00.070 --> 02:03.310
telegram is the output field from here.

02:03.350 --> 02:04.190
Perfect.

02:04.510 --> 02:06.110
There is an easier way of doing this.

02:06.150 --> 02:07.390
You probably guessed this.

02:07.390 --> 02:08.830
I didn't need to type that in there.

02:08.830 --> 02:13.510
I can actually take this drag and drop it in there and it does it for me.

02:13.510 --> 02:18.950
But I did want you to have complete understanding of what's going in there and why, to make sure that

02:18.950 --> 02:23.910
the output of the data that's coming in is what will be passed in to telegram.

02:23.950 --> 02:28.670
Okay, now it's time for chat ID, and this one is a little bit more tricky.

02:29.150 --> 02:33.670
Click in chat ID again, we can just type in a fixed chat ID we don't want that.

02:33.670 --> 02:35.310
We want it to be an expression.

02:35.870 --> 02:40.390
Okay so we want the chat ID where are we going to find the chat ID.

02:41.070 --> 02:47.630
Well the chat ID is something that we would expect to be coming in at the beginning from telegram.

02:47.870 --> 02:52.550
So we really want to we want to pluck something out of the data that came in at the very start.

02:53.070 --> 02:58.920
If you come over here, you'll see that in this this field of incoming data, there is a drop down here.

02:58.920 --> 03:04.680
And this drop down is where you can select other nodes in this workflow that might have data associated

03:04.680 --> 03:05.240
with them.

03:05.440 --> 03:06.000
Okay.

03:06.120 --> 03:10.920
Go to the drop down and select the telegram trigger which is two nodes back.

03:11.120 --> 03:15.240
If anything has the information about this telegram chat it will be the telegram trigger.

03:15.400 --> 03:16.520
Let's select it.

03:16.680 --> 03:20.920
This is the data that came from the telegram trigger in JSON.

03:20.960 --> 03:22.160
Let's look at this.

03:22.160 --> 03:24.880
There's a message ID there's a chat.

03:24.880 --> 03:26.760
There's a chat ID.

03:27.080 --> 03:31.000
Well, that seems like something that belongs right there, right.

03:31.320 --> 03:31.880
Okay.

03:32.080 --> 03:33.040
Wouldn't it be nice?

03:33.080 --> 03:37.920
Wouldn't it be nice if you could just select expression here and then you could just go here, click

03:37.920 --> 03:42.200
and hold down and drag that to chat ID and let go.

03:42.360 --> 03:43.520
Wouldn't it be nice.

03:43.560 --> 03:44.600
It is nice.

03:44.640 --> 03:46.480
That's exactly what you can do.

03:46.480 --> 03:51.160
And if you take a look at this, whilst you might not have been able to write it yourself first time

03:51.360 --> 03:53.520
since we we covered some of this before.

03:53.760 --> 03:56.560
Hopefully you have intuition as to what this is doing.

03:56.560 --> 03:59.410
It's taking the telegram trigger node.

03:59.410 --> 04:03.210
This is actually a shorthand for that, that dollar node thing I showed you before.

04:03.530 --> 04:11.490
So it's taking the telegram trigger node and it's taking item message chat ID it's drilling all the

04:11.490 --> 04:12.450
way down to here.

04:12.650 --> 04:16.410
But you don't need to know how to write this yourself because you can always drag and drop.

04:16.570 --> 04:18.530
It's so simple okay.

04:19.090 --> 04:22.770
And you can see down there it gives the results and you can see that that seems to match.

04:23.010 --> 04:23.890
That's cool.

04:24.170 --> 04:25.010
All right.

04:25.050 --> 04:28.490
Let's, uh, let's go back and see if we can't give this thing a whirl.

04:28.810 --> 04:29.530
Okay.

04:29.730 --> 04:36.730
So first up I'm going to press Execute Workflow which sets the thing running waiting for a trigger event.

04:37.210 --> 04:37.770
All right.

04:37.770 --> 04:40.530
Let's bring Telegram's window over here.

04:40.570 --> 04:41.890
Move it to the side.

04:42.210 --> 04:44.090
And I'm going to say uh.

04:44.130 --> 04:44.970
Hi there.

04:45.970 --> 04:49.330
Uh, what's two plus two that started off light.

04:49.730 --> 04:52.170
Uh, and let it do its thing.

04:52.490 --> 04:54.690
Everything is running high.

04:54.730 --> 04:55.970
Two plus two equals four.

04:56.010 --> 04:57.430
How can I assist you further?

04:58.470 --> 05:00.830
Wow, that just worked.

05:00.870 --> 05:03.790
We just had the workflow happening.

05:03.790 --> 05:06.950
We were just able to get a chat to run.

05:06.990 --> 05:09.830
We were able to bring in the information from the telegram trigger.

05:09.870 --> 05:12.030
We were able to process it in an AI agent.

05:12.030 --> 05:13.990
We're able to send the message back.

05:14.030 --> 05:19.350
And because of the way we hooked up the data, the message that came from the AI agent was was sent

05:19.350 --> 05:26.150
back to telegram, and the chat ID linked it with the incoming message such that the response appeared

05:26.150 --> 05:28.150
here in the telegram window.

05:29.070 --> 05:29.990
That's fabulous.

05:30.070 --> 05:34.710
Now, I mentioned there's one more little fiddly thing, the simple memory here.

05:34.710 --> 05:42.230
It has a problem because it needs to have a session key, some key to tell it uniquely how to identify

05:42.390 --> 05:43.830
this conversation.

05:43.830 --> 05:50.230
And it's it's, uh, initially defaults to this because it thinks it's connected to a chat trigger,

05:50.230 --> 05:51.790
and that's not going to work.

05:52.030 --> 05:52.550
Okay.

05:52.790 --> 05:58.520
So we really want something that is somehow going to give it some memory associated with this particular

05:58.520 --> 05:58.800
chat.

05:58.800 --> 06:00.000
Do we have anything like that?

06:00.040 --> 06:01.080
Well, maybe we do.

06:01.280 --> 06:07.160
So let's first of all click here and say define below so that we can give ourselves an expression.

06:07.360 --> 06:12.040
In this key we're going to click expression so we can have anything we want in there.

06:12.040 --> 06:14.120
And let's take the chat ID.

06:14.360 --> 06:15.680
Let's drop that in there.

06:15.680 --> 06:20.160
And now we are hooking up this memory to this particular chat ID.

06:20.440 --> 06:22.040
That seems like it's common sense.

06:22.360 --> 06:23.000
All right.

06:23.040 --> 06:24.200
Let's give this a whirl.

06:24.360 --> 06:24.840
All right.

06:24.840 --> 06:30.400
Back I've come to the workflow and I've made sure that the simple memory is is is activated again.

06:30.400 --> 06:31.080
It was turned off.

06:31.080 --> 06:31.920
We turned it on.

06:32.200 --> 06:36.320
Uh, and, uh, we will press the execute workflow button.

06:36.480 --> 06:39.800
I'm going to come over here and I'm going to say hi there.

06:40.160 --> 06:42.400
My name is Ed.

06:43.400 --> 06:44.480
I'll let it do its thing.

06:44.960 --> 06:45.600
Hi Ed.

06:45.640 --> 06:46.280
Nice to meet you.

06:46.320 --> 06:47.560
How can I assist you today?

06:47.800 --> 06:49.200
And I'll say what's my name?

06:52.160 --> 06:54.000
And I'll press execute workflow again.

06:54.000 --> 06:54.960
Move that out here.

06:55.060 --> 06:56.340
Execute workflow again.

06:56.940 --> 06:57.940
And here we go.

06:57.980 --> 06:58.820
Your name is Ed.

06:58.860 --> 07:00.180
How may I assist you further?

07:00.500 --> 07:01.940
So there we have it.

07:02.020 --> 07:02.980
It works.

07:03.020 --> 07:08.220
The memory is there, and you can experiment with smarter ways of doing this.

07:08.220 --> 07:08.900
So you.

07:09.020 --> 07:14.300
If we look in this memory, you can see that we attached it to this chat ID, which might make sense,

07:14.300 --> 07:18.940
but you could also attach it instead to the username, the telegram username.

07:18.940 --> 07:24.020
And that way the memory will persist between different chat sessions with the same telegram user.

07:24.020 --> 07:25.380
And that might be even better.

07:25.380 --> 07:27.460
So you should experiment with that.

07:27.820 --> 07:33.340
Okay, so we have just built a two way integration with telegram.

07:33.460 --> 07:37.540
We have it so that telegram, when messages are sent it gets triggered.

07:37.660 --> 07:40.060
And we are then able to respond.

07:40.060 --> 07:44.740
And those responses get posted back to telegram in the same chat ID.

07:44.860 --> 07:49.300
And we have memory that's attached to that chat ID as it happens as of now.

07:49.500 --> 07:51.460
And it's all working.

07:51.780 --> 07:56.750
There's one more little thing, a little wrinkle in here, which is the way we keep having to press

07:56.750 --> 08:03.270
the execute workflow button, which is kind of annoying every time that we want to respond to suck something

08:03.270 --> 08:05.150
out of telegram, we can't be doing that.

08:05.150 --> 08:07.390
That doesn't feel very automated, does it?

08:07.390 --> 08:07.950
Okay.

08:08.150 --> 08:11.270
It's time for us to publish our first workflow.

08:11.310 --> 08:14.830
Everything we've been doing up to this point has been in test mode.

08:14.830 --> 08:18.590
We've built a workflow, and then we've pressed the Execute workflow button.

08:18.590 --> 08:22.950
That means we're testing it and we've seen the different the boxes light up as they run.

08:23.190 --> 08:28.070
That's not the way that you finally deliver an NM workflow when you've finished it.

08:28.070 --> 08:32.310
The way you deliver it is by pressing the publish button, so we'll save it first.

08:32.310 --> 08:33.710
When you publish it.

08:33.710 --> 08:40.950
This whole workflow goes live as like a running thing in the world, and you won't see boxes highlight

08:40.950 --> 08:42.790
anymore because it will just all be running.

08:43.070 --> 08:44.110
Let's give it a whirl.

08:44.110 --> 08:46.110
We're going to press the publish button.

08:46.110 --> 08:47.430
It wants a version name.

08:47.430 --> 08:50.030
You can give it whatever you want and describe the changes.

08:50.030 --> 08:56.320
We press publish and it says the workflow is now published, it will listen for events from telegram.

08:56.400 --> 08:57.160
Got it.

08:57.320 --> 09:00.000
Okay, uh, let's let's give this a try.

09:00.040 --> 09:03.880
Let's actually message our workflow running in production.

09:03.920 --> 09:05.680
All right, here we go.

09:05.880 --> 09:07.880
Let's start by saying hi there.

09:11.320 --> 09:12.160
Hello, editor.

09:12.320 --> 09:13.720
Sorry I closed down the bot father here.

09:13.960 --> 09:14.120
Uh.

09:14.120 --> 09:14.680
Hello, editor.

09:14.680 --> 09:16.080
How can I help you today?

09:16.560 --> 09:16.920
Uh.

09:17.320 --> 09:22.000
All right, um, what's the current date?

09:23.320 --> 09:24.200
See how it does.

09:24.600 --> 09:26.800
We're hoping that the tool is being called.

09:26.800 --> 09:27.920
The current date is.

09:27.960 --> 09:30.800
And yes, that does indeed appear to be the current date for me.

09:30.880 --> 09:32.520
Hopefully you will have a different date.

09:32.560 --> 09:33.840
December the 15th.

09:34.000 --> 09:35.080
It worked.

09:35.120 --> 09:36.440
This is running.

09:36.440 --> 09:41.400
We have a telegram connectivity both ways and using a tool.

09:41.560 --> 09:42.680
And we've deployed it.

09:42.720 --> 09:44.040
We've published it.

09:44.040 --> 09:45.040
This is running live.

09:45.040 --> 09:48.640
No longer do we see the boxes lighting up because we're not testing.

09:48.640 --> 09:51.160
This is running in production.

09:51.360 --> 09:52.980
And so you should now do this.

09:53.020 --> 09:53.420
If.

09:53.540 --> 09:55.780
If you have telegram, then you should hook up.

09:55.780 --> 09:56.740
You should make the trigger.

09:56.740 --> 10:01.060
You should send the text message and then have a tool that you like.

10:01.100 --> 10:07.780
And then press publish and try this out so that you can have your first deployed workflow running.

10:07.820 --> 10:09.100
Congratulations.

10:09.100 --> 10:12.020
That's that's a much more meaty integration.

10:12.020 --> 10:19.100
And now at this point, uh, go to this triple dots up here and select Unpublish to stop it from being

10:19.100 --> 10:20.900
published and unpublished.

10:20.900 --> 10:21.620
There we go.

10:21.660 --> 10:23.300
Unpublished successfully.

10:23.580 --> 10:24.660
That is done.

10:24.660 --> 10:32.620
You can give it a nice name telegram workflow up at the top by clicking there, and then press save

10:32.780 --> 10:34.900
and then go back and we'll see.

10:34.900 --> 10:37.140
The telegram workflow is completed.

10:37.700 --> 10:42.620
So we've talked a lot of boxes, a more in-depth integration and publishing to production.

10:43.020 --> 10:45.660
It's now time for the final integration of today.

10:45.740 --> 10:50.700
And I tell you, if you thought this one was a little bit grueling, the next one is more grueling.

10:50.700 --> 10:52.420
It's time for slack.
