-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZapierIntegration.cs
36 lines (31 loc) · 1.09 KB
/
ZapierIntegration.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace ChatGPTBasedBot
{
internal class ZapierIntegration
{
private readonly string _webhookUrl;
public ZapierIntegration(string webhookUrl)
{
_webhookUrl = webhookUrl;
}
public async Task PostToZapierAsync(string message, byte[] imageData, string fileName)
{
using (var client = new HttpClient())
{
using (var content = new MultipartFormDataContent())
{
content.Add(new StringContent(message), "message");
var imageContent = new ByteArrayContent(imageData);
imageContent.Headers.ContentType = MediaTypeHeaderValue.Parse("image/jpeg");
content.Add(imageContent, "file", fileName);
var response = await client.PostAsync(_webhookUrl, content);
response.EnsureSuccessStatusCode();
}
}
}
}
}