File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
app/(protected)/api/webhook/instagram Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,15 @@ export async function POST(req: NextRequest) {
183
183
automation . User ?. integrations [ 0 ] . token !
184
184
) ;
185
185
186
+ if ( automation . listener . commentReply ) {
187
+ await sendPrivateMessage (
188
+ webhook_payload . entry [ 0 ] . id ,
189
+ webhook_payload . entry [ 0 ] . changes [ 0 ] . value . id ,
190
+ automation . listener . commentReply ,
191
+ automation . User ?. integrations [ 0 ] . token !
192
+ ) ;
193
+ }
194
+
186
195
console . log ( "DM SENT" , direct_message . data ) ;
187
196
if ( direct_message . status === 200 ) {
188
197
const tracked = await trackResponses ( automation . id , "COMMENT" ) ;
Original file line number Diff line number Diff line change @@ -60,6 +60,27 @@ export const sendPrivateMessage = async (
60
60
) ;
61
61
} ;
62
62
63
+ export const sendCommentReply = async (
64
+ userId : string ,
65
+ commentId : string ,
66
+ reply : string ,
67
+ token : string
68
+ ) => {
69
+ console . log ( "sending comment reply" ) ;
70
+ return await axios . post (
71
+ `${ process . env . INSTAGRAM_BASE_URL } /${ userId } /media/${ commentId } /replies` ,
72
+ {
73
+ message : reply ,
74
+ } ,
75
+ {
76
+ headers : {
77
+ Authorization : `Bearer ${ token } ` ,
78
+ "Content-Type" : "application/json" ,
79
+ } ,
80
+ }
81
+ ) ;
82
+ } ;
83
+
63
84
export const generateTokens = async ( code : string ) => {
64
85
try {
65
86
// Validate input
You can’t perform that action at this time.
0 commit comments