Transcript for:
Instagram DMs Integration Guide

if you want to add an N8N AI agent into Instagram DMs quickly and easily then this video is for you i'll show you exactly how to do that with Many Chat and at the end of the video I'm going to share the template with you completely for free so the AI agent we're going to be integrating is one that I've built for a previous video you can also access this AI agent template for free if we go ahead and simply test the conversation right here we can see that it actually works and that this agent does trigger responses and we're going to be integrating this inside of ManyHat we have the AI agent we have OpenAI connected we have window buffer memory and we have a vector store for our knowledge base you can check out the other video right here if you want to learn how to set this up specifically now as for ManyHat it allows you to automate DMs on platforms like Instagram Facebook WhatsApp and more in this case we're going to be doing Instagram and we have a free template for this in our school community at school.com/omnifusion once you sign up to ManyHat the link is down below in the description there's a 14-day free trial all you need to do do is go to settings go to Instagram and simply connect your Instagram account right here after that you're going to go ahead and go to school.com/omnifusion get the free template and you're going to have the ManyHat XN8N template which you can import directly into your ManyHat by clicking the link once you have that this flow here is going to open up now you don't need to know much of what's going on here the important thing is we're waiting 10 seconds after every message to see if they send another message so that we can reply to multiple messages in one go instead of sending a new message for every single message that a user sends and you need to replace an app script right here i'm not going to show you how to do this in this video but there's a very easy step-by-step guide in the school community so that you can get your own appcript URL and add it in here now you also have the N8N node which I'm going to show you in just a second and apart from that we're sending out a message at the end now if a contact has not responded we currently send a follow-up message which you can configure by going here clicking on the contacts reply and if the contact has not responded in X amount of time you can go ahead and send this follow-up message you can adjust this as needed or remove the follow-up message if you want to but this is the flow right here now we're going to go ahead and set this up which is actually very easy for this we're simply going to go back to NAT we're going to go ahead and find the web hook node which we're going to add here and we're going to connect it to the AI agent now for the web hook node it's important to change it to a post web hook and we're going to respond using the respond to web hook node this is very important to set it up this way we're then also going to go to the right side of the AI agent and we're going to find the respond to web hook node we're going to go into the respond to web hook node and what's very important here is that we're going to simply go ahead and execute the previous nodes and we're going to click on respond with we're going to select JSON and we're going to select an expression and in this expression we're going to copy in this template right here this is going to be available for you for free in the school community we're simply going to have this here we're going to click on save and make sure that this is active now first thing we're going to do is we're going to go ahead and click on the web hook we're going to click on test URL and we're going to go ahead and copy out this test URL we're going to click on listen for test event we're going to go to ManyHat we're going to go to the N8N node we're going to paste in the N8N URL and we're going to select a contact for testing in this case it should have my personal Instagram account as a contact for testing clearly it doesn't in order to resolve that simply DM yourself on the Instagram account that you just connected to ManyHat now that I've gone ahead and done that we have the contact right here and I can go ahead and click on test request this has now sent the test request to NHN and we can now now move along with that as you can see we have the session ID we have the name and we have the message which in this case is empty because we didn't actually send a message what we're going to do is we're now going to go to the AI agent we're going to select the source for the prompt which is going to be defined below we're going to change this to expression and we're going to go ahead and select the message and drag it in here we're also going to need the session ID we're going to drag that in here but we're not going to leave it here we're going to copy it out we're going to go to the memory and this is going to allow the agent to know which user it's talking to and have separate memory for every single session we're going to click on define below click on expression and paste this in here we're then going to go to the respond to web hook node click on execute previous nodes which is going to execute the AI agent based on the inputs and we're going to respond with text selecting an expression and dragging in the output from there over here we now have everything set up we can go ahead and click on save make sure this is toggled to active and we're going to go to the workflow click on production URL we're going to copy this we're now going to replace the URL in the top right here with the production URL we're going to select the contact for testing again and we're going to click on test request now it's going to give us the response from the AI and as you can see it's in the response body right here the response mapping right here is already taken care of for you so it's going to map the reply from the NAT agent to the last reply node over here now like I mentioned you need to go ahead and set up the app script by following the tutorial i'm going to do that real quick and then I'm going to get back to you now that this is done you can simply go ahead and click on update or go live and now the entire flow is live now you may notice that we need a trigger right here now in order to trigger this for every single message I'm going to show you how to do that in a second or you can have this run only if somebody clicks an ad or if somebody sends a message with a specific keyword if we want to trigger for every single message we're going to go to settings go to Instagram click on select existing and select the ManyHat XN8N template we're going to go ahead and click on pick this automation we can click here to go back inside the automation click on edit and if we go to the trigger you need to make sure that this is set to every time by default if you're a new ManyHat user it's going to be set to once per 24 hours which we don't want we want it to trigger for every single message now that that is done we can actually go ahead and test this in order to test it I'm going to go to my contact i'm going to go ahead and delete this contact by typing in delete now that we've deleted the contact we can simply go ahead and test the agent again we're going to go ahead and go to Instagram and say "Hey." Now as you can see the message shows up inside of ManyHat if we go into N8N and we go to executions if we simply wait a little bit it's going to show the new execution right here as you can see it's currently running if we go into the AI agent we can see we got a response and we also got the message saying "Hey." If we go back into ManyHat we can see that we actually sent out the message and if we go back into Instagram we can see that we got the reply back from our AI agent inside of Instagram DMs and that is it for this video if you want access to the ManyHat template the NHN template and many more resources and templates that we have available please join our free school community at school.com/omnifusion and if you're interested in us building out an AI sales agent for your business this is only for people who have an active lead flow which they're struggling to manage please go ahead and visit omnifusion.ai we'll be more than happy to chat with you and see if it's a good fit and we can create a win-win situation i'll see you guys in the next video and I hope you have a fantastic